Created
October 18, 2011 11:59
-
-
Save Ephigenia/1295266 to your computer and use it in GitHub Desktop.
PHP-upload-file-errors
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // test if a file was uploaded | |
| $formFieldName = 'myFile'; | |
| if (isset($_FILES[$formFieldName])) { | |
| switch(@$_FILES[$formFieldName]['error']) { | |
| case UPLOAD_ERR_OK: // 0 | |
| // everything is ok with the upload for php | |
| break; | |
| case UPLOAD_ERR_INI_SIZE: | |
| // file is larger than the size set in php.ini | |
| // upload_max_filesize | |
| break; | |
| case UPLOAD_ERR_FORM_SIZE: | |
| // file exceeds size set in form | |
| break; | |
| case UPLOAD_ERR_PARTIAL: | |
| // file upload | |
| break; | |
| case UPLOAD_ERR_NO_FILE: | |
| // no file was specified (empty form field) | |
| break; | |
| case UPLOAD_ERR_NO_TMP_DIR: | |
| // no tmp dir specified in php.ini | |
| break; | |
| case UPLOAD_ERR_CANT_WRITE: | |
| // tmp dir from php.ini is not writable for php | |
| break; | |
| default: | |
| // unknown error code | |
| break; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment