I want to have a HTTP POST to a PHP script which includes a file upload. The PHP script should reject any file which is not the right type, or otherwise malformed.
This means
- the PHP script begins executing before the upload is complete,
- it reads the first X bytes of the file, and
- maybe abort the connection before upload is complete.
How do I do each of these?
PHP can't abort uploads. But you can validate
$_FILES
after the file was completly uploaded.See:
http://php.net/manual/en/features.file-upload.post-method.php
You could limit the file size in your php.ini
http://www.php.net/manual/en/ini.core.php#ini.upload-max-filesize
This is the maximum you can get.