note 90522 added to features.file-upload.errors
| From: | (nhtngindottde) | Date: | Sun, 26 Apr 2009 16:43:48 +0000 |
| Subject: | note 90522 added to features.file-upload.errors | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-153785@lists.php.net to get a copy of this message | ||
Why make stuff complicated when you can make it easy?
[Edit of edit by danbrown AT php DOT net: This code is a fixed version of a note originally
submitted by (Thalent, Michiel Thalen) on 04-Mar-2009.]
<?php
function file_upload_error_message($error_code) {
switch ($error_code) {
case UPLOAD_ERR_INI_SIZE:
return 'The uploaded file exceeds the upload_max_filesize directive in php.ini';
case UPLOAD_ERR_FORM_SIZE:
return 'The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML
form';
case UPLOAD_ERR_PARTIAL:
return 'The uploaded file was only partially uploaded';
case UPLOAD_ERR_NO_FILE:
return 'No file was uploaded';
case UPLOAD_ERR_NO_TMP_DIR:
return 'Missing a temporary folder';
case UPLOAD_ERR_CANT_WRITE:
return 'Failed to write file to disk';
case UPLOAD_ERR_EXTENSION:
return 'File upload stopped by extension';
default:
return 'Unknown upload error';
}
}
// Example
if ($_FILES['file']['error'] === UPLOAD_ERR_OK)
// upload ok
else
$error_message = file_upload_error_message($_FILES['file']['error']);
?>
----
Server IP: 217.13.201.10
Probable Submitter: 88.70.68.202
----
Manual Page -- http://www.php.net/manual/en/features.file-upload.errors.php
Edit -- https://master.php.net/note/edit/90522
Del: integrated -- https://master.php.net/note/delete/90522/integrated
Del: useless -- https://master.php.net/note/delete/90522/useless
Del: bad code -- https://master.php.net/note/delete/90522/bad+code
Del: spam -- https://master.php.net/note/delete/90522/spam
Del: non-english -- https://master.php.net/note/delete/90522/non-english
Del: in docs -- https://master.php.net/note/delete/90522/in+docs
Del: other reasons-- https://master.php.net/note/delete/90522
Reject -- https://master.php.net/note/reject/90522
Search -- https://master.php.net/manage/user-notes.php