PHP and HTML Problem: Why does Uploading files input not work with some files?

mina S

New member
I created an upload system with php .But the input of files doesn't send any data from SOME files(more than 1MB or 2MB).Why?
<form method="post" enctype="multipart/form-data"><input name="userfile" type="file" /></form>
(I don't wanna upload the files.I just want to save the NAME of the files into database)
 
check the php.ini

When trying to upload a large file nothing is uploaded and the browser seems to "refresh" without any error generation.

Solution (set the following two directives in the php.ini):

post_max_size
upload_max_filesize


This is assuming you have access to the php.ini. You will have to set them to a little bit more than you are willing to allow for file upload and error check/validate the $_FILES['file_to_upload']['size'] against what you want.

Sample code:


Code:
<?
//The max in MB you are willing to allow
$max_allow = 10;
if($_FILES['file_to_upload']['size'] >= pow(1024,2) * $max_allow){
echo "Your file is too large to upload. Try something smaller!";
}
?>

and these directives can not be set with ini_set();
 
Back
Top