note 38683 added to features.file-upload

From: Date: Fri, 02 Jan 2004 19:21:15 +0000
Subject: note 38683 added to features.file-upload
Groups: php.notes 
Request: Send a blank email to php-notes+get-62802@lists.php.net to get a copy of this message
Ever wonder what the error is? Here's code to display the image upload error code and text: <?php if (version_compare( phpversion(), "4.2.0") > 0) { // this reporting available 4.2.0 or higher only // give full reporting about file upload, regardless of result echo "<h2>Internal PHP Report about file upload</h2>"; $upload_error_no = $_FILES['userfile']['error']; switch($upload_error_no) { case 0: echo "<h4>UPLOAD_ERR_OK</h4>"; echo "upload error # $upload_error_no<br> There is no error, the file uploaded with success."; break; case 1: echo "<h4>UPLOAD_ERR_INI_SIZE</h4>"; echo "upload error # 1<br> The uploaded file exceeds the upload_max_filesize directive in php.ini."; break; case 2: echo "<h4>UPLOAD_ERR_FORM_SIZE</h4>"; echo "upload error # 2<br> The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the html form."; break; case 3: echo "<h4>UPLOAD_ERR_PARTIAL</h4>"; echo "upload error # 3<br> The uploaded file was only partially uploaded."; break; case 4: echo "<h4>UPLOAD_ERR_NO_FILE</h4>"; echo "upload error # 4<br> No file was uploaded."; break; default: echo "Out of range upload error number of &quot;$upload_error_no&quot; for switch(upload_error_no)"; } } ?> ---- Manual Page -- http://www.php.net/manual/en/features.file-upload.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+38683 Delete -- http://master.php.net/manage/user-notes.php?action=delete+38683&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+38683&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#62802) next »