note 115808 added to features.file-upload.errors

From: Date: Fri, 26 Sep 2014 21:11:50 +0000
Subject: note 115808 added to features.file-upload.errors
Groups: php.notes 
Request: Send a blank email to php-notes+get-200531@lists.php.net to get a copy of this message
This updates "adam at gotlinux dot us" above and makes it version aware, and also adds newer constants to the array. The reason we want to check the version is that the constants are not defined in earlier versions, and they appear later in the array. They would effectively overwrite the "0" index (no error) with an error message when the file actually uploaded fine. It also drops the constant's value (0,1,2, etc) for the errors, in the likely event that they are changed later (the code should still work fine). <?php $upload_errors = array( 0 => "There is no error, the file uploaded with success" ,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" ); if (version_compare(PHP_VERSION, '5.0.3') >= 0) $upload_errors[UPLOAD_ERR_NO_TMP_DIR] = "Missing a temporary folder"; if (version_compare(PHP_VERSION, '5.1.0') >= 0) $upload_errors[UPLOAD_ERR_CANT_WRITE] = "Failed to write to disk"; if (version_compare(PHP_VERSION, '5.2.0') >= 0) $upload_errors[UPLOAD_ERR_EXTENSION] = "File upload stopped by extension"; ?> ---- Server IP: 72.52.91.14 Probable Submitter: 4.30.168.98 ---- Manual Page -- http://php.net/manual/en/features.file-upload.errors.php Edit -- https://master.php.net/note/edit/115808 Del: integrated -- https://master.php.net/note/delete/115808/integrated Del: useless -- https://master.php.net/note/delete/115808/useless Del: bad code -- https://master.php.net/note/delete/115808/bad+code Del: spam -- https://master.php.net/note/delete/115808/spam Del: non-english -- https://master.php.net/note/delete/115808/non-english Del: in docs -- https://master.php.net/note/delete/115808/in+docs Del: other reasons-- https://master.php.net/note/delete/115808 Reject -- https://master.php.net/note/reject/115808 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#200531) next »