Jump to content

checking file size


etsted
 Share

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 />";
}
Link to comment
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

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...