note 80575 added to features.file-upload.errors
| From: | albertat374cdotnl at osu1 dot php dot net | Date: | Wed, 23 Jan 2008 08:32:36 +0000 |
| Subject: | note 80575 added to features.file-upload.errors | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-135327@lists.php.net to get a copy of this message | ||
@Anonymous [below me]
If a new error constant would be introduced, your script would ignore it and assume that the upload
went OK.
I've included a better version below:
<?php
$uploadErrors = array(
UPLOAD_ERR_INI_SIZE => 'The uploaded file exceeds the upload_max_filesize directive in
php.ini.',
UPLOAD_ERR_FORM_SIZE => 'The uploaded file exceeds the MAX_FILE_SIZE directive that was
specified in the HTML form.',
UPLOAD_ERR_PARTIAL => 'The uploaded file was only partially uploaded.',
UPLOAD_ERR_NO_FILE => 'No file was uploaded.',
UPLOAD_ERR_NO_TMP_DIR => 'Missing a temporary folder.',
UPLOAD_ERR_CANT_WRITE => 'Failed to write file to disk.',
UPLOAD_ERR_EXTENSION => 'File upload stopped by extension.',
);
$errorCode = $_FILES['myUpload']['error'];
// if($errorCode !== UPLOAD_ERR_OK && isset($uploadErrors[$errorCode]))
if($errorCode !== UPLOAD_ERR_OK)
{
if(isset($uploadErrors[$errorCode]))
throw new Exception($uploadErrors[$errorCode]);
else
throw new Exception("Unknown error uploading file.");
}
?>
----
Server IP: 89.248.170.58
Probable Submitter: 62.216.11.79
----
Manual Page -- http://www.php.net/manual/en/features.file-upload.errors.php
Edit -- https://master.php.net/note/edit/80575
Del: integrated -- https://master.php.net/note/delete/80575/integrated
Del: useless -- https://master.php.net/note/delete/80575/useless
Del: bad code -- https://master.php.net/note/delete/80575/bad+code
Del: spam -- https://master.php.net/note/delete/80575/spam
Del: non-english -- https://master.php.net/note/delete/80575/non-english
Del: in docs -- https://master.php.net/note/delete/80575/in+docs
Del: other reasons-- https://master.php.net/note/delete/80575
Reject -- https://master.php.net/note/reject/80575
Search -- https://master.php.net/manage/user-notes.php