I have the form below
<form method='post' action=upload_file2.php enctype='multipart/form-data'>
<input type='hidden' name='MAX_FILE_SIZE' value='100000'>
Enter the File <input type='file' name='userfile'> <br>
<input type='submit' name='submit' value='Send File'>
When i am attempting to upload a file bigger than the limitation of 100000 bytes an error is displayed like
Warning: MAX_FILE_SIZE of 100000 bytes exceeded - file [userfile=C:\My Documents\Easy_CD-DA_Extractor_v4[1].6.9_by_Twice.zip] not saved in Unknown on line 0
100000
Warning: getimagesize: Unable to open '' for reading. in c:\phpdev\www\tests\upload_file2.php on line 5
My
upload_file2.php
<? if($_FILES['userfile']['name']) {
echo $_POST['MAX_FILE_SIZE'];
echo $_FILE['userfile']['size'];
if(($_FILE['userfile']['size'])<=($_POST['MAX_FILE_SIZE'])) {
$type_image=getimagesize($_FILES['userfile']['tmp_name']);
if($type_image[2]){
$name=$_FILES['userfile']['name'];
if (is_uploaded_file($_FILES['userfile']['tmp_name']))
{
copy($_FILES['userfile']['tmp_name'], "images/".$name);
mysql_connect("localhost");mysql_select_db("authentication");
$result=mysql_query("SELECT id FROM images ORDER BY id DESC LIMIT 1");
$prefix=mysql_fetch_assoc($result);
$i=$prefix['id'];
$new_prefix=++$i;
$extention=substr($name,strrpos($name,"."));
echo $newFileName=$new_prefix.$extention;
rename("images/$name","images/$newFileName");
mysql_query("INSERT INTO images VALUES ('','$newFileName')");
mysql_close();
unlink($_FILES['userfile']['tmp_name']);
//optional
echo "<br> File successfully Uploaded And Renamed";
echo "<img src=images/".$newFileName.">";}}
else echo"You must enter an image file";}
else echo "The file exceeds the restriction";
} else echo "You must enter file";
?>
In this manner i am trying to filter the size of the file.
But the error message remains.
What can i do in order to solve this problem?