Forum Moderators: coopster
<?php
$file_realname = trim($_FILES['userfile']['name']);
$uploaddir = "images/";if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploaddir . $file_realname))
{
echo $file_realname." has been uploaded";
}
else
{
echo "<strong>$file_realname</strong> did not upload!";
}
?>
And I get this kind of error when I tries to upload a big file.
Notice: Undefined index: userfile in C:\Program Files\Apache Group\Apache2\htdocs\FYP\upload\upload.php on line 2
Notice: Undefined index: userfile in C:\Program Files\Apache Group\Apache2\htdocs\FYP\upload\upload.php on line 5
did not upload!
Is there a way to expend the limit of the file size? And restrict user to upload all know pictures type only.
[us3.php.net...] looks like it had some more info on restriction the file upload, but I've never tried it.
I changed my php.ini to allow a max upload of 1MB. And I did so in my form too.
<input type="hidden" name="MAX_FILE_SIZE" value="1048576">
Yes the browser does catch the error now. Displaying error code 2. Which means "Value: 2; The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form."
This error works all the way until 10MB only. After 10MB...
Notice: Undefined index: userfile in C:\Program Files\Apache Group\Apache2\htdocs\FYP\admin\upload.php on line 2
Notice: Undefined index: userfile in C:\Program Files\Apache Group\Apache2\htdocs\FYP\admin\upload.php on line 5
did not upload!
Notice: Undefined index: userfile in C:\Program Files\Apache Group\Apache2\htdocs\FYP\admin\upload.php on line 13
And I had wanted to rename my files afer they are uploaded. Figured that $_FILES['userfile']['name'] gets the full name together with the extension. So when I change my file name. It is without extension. How do I change it so that only the name changes but the extension remains?