PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Got sort of a weird problem here. I've wirtten my own file upload class file but Ive been finding that my browser (Firefox 1.5 on Linux) is not sending the tmp_name or my script just isnt recieving it.
Im accessing the $_FILES array correctly and using move_uploaded_file() with an absolute path, everything is normal there but here's the print_r:
The client/browser does not care about the name="MAX_FILE_SIZE" field (at least I don't know a browser that does. My Firefox certainly doesn't).
PHP checks that value. It does not overwrite upload_max_filesize, both values are checked. But since MAX_FILE_SIZE is sent by the client along with the payload it's not trustworthy, do not rely on that feature.
volka wrote:The client/browser does not care about the name="MAX_FILE_SIZE" field (at least I don't know a browser that does. My Firefox certainly doesn't).
PHP checks that value. It does not overwrite upload_max_filesize, both values are checked. But since MAX_FILE_SIZE is sent by the client along with the payload it's not trustworthy, do not rely on that feature.
Okay. So, what is the use of "MAX_FILE_SIZE" in file upload ? I also don't rely in this feature and just validate the size using server side features.
Some browsers specify what the size of the file being sent is in the request headers. PHP can filter the file in this manor so that neither party wastes bandwidth they don't need to because the file is beyond acceptable limitations. As previously said, you still need to check the error flag and size fields to verify, but that should be standard procedure for everyone, shouldn't it?
$_FILES['userfile']['error'].
UPLOAD_ERR_OK
Value: 0; There is no error, the file uploaded with success.
UPLOAD_ERR_INI_SIZE
Value: 1; The uploaded file exceeds the upload_max_filesize directive in php.ini.
UPLOAD_ERR_FORM_SIZE
Value: 2; The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.
UPLOAD_ERR_PARTIAL
Value: 3; The uploaded file was only partially uploaded.
UPLOAD_ERR_NO_FILE
Value: 4; No file was uploaded.
UPLOAD_ERR_NO_TMP_DIR
Value: 6; Missing a temporary folder. Introduced in PHP 4.3.10 and PHP 5.0.3.
UPLOAD_ERR_CANT_WRITE
Value: 7; Failed to write file to disk. Introduced in PHP 5.1.0.