note 67931 added to features.file-upload.errors

From: Date: Thu, 06 Jul 2006 21:53:38 +0000
Subject: note 67931 added to features.file-upload.errors
Groups: php.notes 
Request: Send a blank email to php-notes+get-114523@lists.php.net to get a copy of this message
In response to Hans: The problem with your switch statement is that it never allows for no errors, i.e. the UPLOAD_ERR_OK val. So to still allow room for further errors, yet notice a no-error case, this needs to be addressed: <?php switch ($filearray["error"]) { case UPLOAD_ERR_OK: break; case UPLOAD_ERR_INI_SIZE: throw new Exception("The uploaded file exceeds the upload_max_filesize directive (".ini_get("upload_max_filesize").") in php.ini."); break; case UPLOAD_ERR_FORM_SIZE: throw new Exception("The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form."); break; case UPLOAD_ERR_PARTIAL: throw new Exception("The uploaded file was only partially uploaded."); break; case UPLOAD_ERR_NO_FILE: throw new Exception("No file was uploaded."); break; case UPLOAD_ERR_NO_TMP_DIR: throw new Exception("Missing a temporary folder."); break; case UPLOAD_ERR_CANT_WRITE: throw new Exception("Failed to write file to disk"); break; default: throw new Exception("Unknown File Error"); } ?> ---- Server IP: 64.71.164.2 Probable Submitter: 66.92.33.37 ---- X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/features.file-upload.errors.php Edit -- http://master.php.net/note/edit/67931 Del: integrated -- http://master.php.net/note/delete/67931/integrated Del: useless -- http://master.php.net/note/delete/67931/useless Del: bad code -- http://master.php.net/note/delete/67931/bad+code Del: spam -- http://master.php.net/note/delete/67931/spam Del: non-english -- http://master.php.net/note/delete/67931/non-english Del: in docs -- http://master.php.net/note/delete/67931/in+docs Del: other reasons-- http://master.php.net/note/delete/67931 Reject -- http://master.php.net/note/reject/67931 Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#114523) next »