| 1 |
lars |
1 |
<?php
|
|
|
2 |
$uploadErrors = array(
|
|
|
3 |
UPLOAD_ERR_INI_SIZE => "The uploaded file exceeds the upload_max_filesize directive in php.ini.",
|
|
|
4 |
UPLOAD_ERR_FORM_SIZE => "The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.",
|
|
|
5 |
UPLOAD_ERR_PARTIAL => "The uploaded file was only partially uploaded.",
|
|
|
6 |
UPLOAD_ERR_NO_FILE => "No file was uploaded.",
|
|
|
7 |
UPLOAD_ERR_NO_TMP_DIR => "Missing a temporary folder.",
|
|
|
8 |
UPLOAD_ERR_CANT_WRITE => "Failed to write file to disk.",
|
|
|
9 |
UPLOAD_ERR_EXTENSION => "File upload stopped by extension.",
|
|
|
10 |
);
|
|
|
11 |
|
|
|
12 |
$errorCode = $_FILES["myUpload"]["error"];
|
|
|
13 |
|
|
|
14 |
if ($errorCode !== UPLOAD_ERR_OK) {
|
|
|
15 |
if (isset($uploadErrors[$errorCode])) {
|
|
|
16 |
throw new Exception($uploadErrors[$errorCode]);
|
|
|
17 |
} else {
|
|
|
18 |
throw new Exception("Unknown error uploading file.");
|
|
|
19 |
}
|
|
|
20 |
}
|
|
|
21 |
?>
|