Jump to content
Sign in to follow this  
etsted

checking file size

Recommended Posts

this is my video upload script, and i have inserted a max file size check, but i doesnt seem to work, every time i upload a script that is larger than 2mb it checkes the other if statment on the script,, which is wheter or not the user has filled out the forms

script:

 

$form ="
<form action='upload.php' method='POST' enctype='multipart/form-data'>
<input type='text' name='title' placeholder='Title' /> <br />
<textarea rows='8' cols='30' name='description'></textarea><br />
<input type='file' name='file' /><br />
<input type='submit' name='submit' />
</form>";
echo $form;
$title = mysql_real_escape_string(htmlentities($_POST['title']));
$description = mysql_real_escape_string(htmlentities($_POST['description']));
if($_FILES["file"]["size"] < 10000000)
{
if($title && $description)
{
$path = pathinfo($_FILES['file']['name']);
$allowed = array('jpg','jpeg','gif','png','swf','MP4','flv','mgp','mpeg','webm','rm','ram','mov','wmv','avi','MPEG-4');
if(in_array($path['extension'],$allowed))
{
include "connect.php";
$name = $_FILES['file']['name'];
$temp = $_FILES['file']['tmp_name'];
move_uploaded_file($temp, "upload/".$name);
mysqli_query($con, "INSERT INTO videos VALUES('','$title','$name','$url','$description')") or die(mysql_error());
echo "<p>You're file has been uploaded.</p> <br />";
mysqli_close($con);
}
else
{
echo "<p>must be a video or a picture</p> <br />";
}
}
else
{
echo "<p>You must fill out the form.</p> <br />";
}
}
else
{
echo "<p>You're file is to big.</p> <br />";
}
}
else
{
echo "<p>You must be logged in, in order to upload a file.</p><br />";
}

Share this post


Link to post
Share on other sites

max file size is probably set in php.ini to a value of 2MB (which might be the default, I think). you will need have access to your php.ini file in order to change it because it cannot be changed at runtime.

http://stackoverflow.com/questions/2184513/php-change-the-maximum-upload-file-size

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...