]>
jfr.im git - uguu.git/blob - static/php/classes/UploadException.class.php
4 * Returns a human readable error description for file upload errors.
6 * @author Dan Brown <danbrown@php.net>
7 * @author Michiel Thalen
8 * @copyright Copyright © 1997 - 2016 by the PHP Documentation Group
10 * UploadException is licensed under a Creative Commons Attribution 3.0 License
14 * https://secure.php.net/manual/en/features.file-upload.errors.php#89374.
16 * You should have received a copy of the Creative Commons Attribution 3.0
17 * License with this program. If not, see
18 * <https://creativecommons.org/licenses/by/3.0/>.
22 class UploadException
extends Exception
24 public function __construct($code)
26 $message = $this->codeToMessage($code);
27 parent
::__construct($message, 500);
30 private function codeToMessage($code)
33 case UPLOAD_ERR_INI_SIZE
:
34 $message = 'The uploaded file exceeds the upload_max_filesize directive in php.ini';
36 case UPLOAD_ERR_FORM_SIZE
:
37 $message = 'The uploaded file exceeds the MAX_FILE_SIZE directive that was '.
38 'specified in the HTML form';
40 case UPLOAD_ERR_PARTIAL
:
41 $message = 'The uploaded file was only partially uploaded';
43 case UPLOAD_ERR_NO_FILE
:
44 $message = 'No file was uploaded';
46 case UPLOAD_ERR_NO_TMP_DIR
:
47 $message = 'Missing a temporary folder';
49 case UPLOAD_ERR_CANT_WRITE
:
50 $message = 'Failed to write file to disk';
52 case UPLOAD_ERR_EXTENSION
:
53 $message = 'File upload stopped by extension';
57 $message = 'Unknown upload error';