summaryrefslogtreecommitdiffstats
path: root/application
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2013-06-23 12:56:40 +0200
committerFlorian Pritz <bluewind@xinu.at>2013-06-23 12:56:40 +0200
commit3bad31691aa6689f1b185fd8f37ba91f0aba8673 (patch)
treef9ae6c256f9d1bdd186192614ceb469fce37d73e /application
parent73d6d76ec4d1c8bc9fce9ba1a1dcf8fa6735f621 (diff)
c/file: improve upload error handling
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'application')
-rw-r--r--application/controllers/file.php24
1 files changed, 16 insertions, 8 deletions
diff --git a/application/controllers/file.php b/application/controllers/file.php
index 1c216aa15..851afa9b7 100644
--- a/application/controllers/file.php
+++ b/application/controllers/file.php
@@ -572,22 +572,30 @@ class File extends CI_Controller {
// First error wins and is displayed, these shouldn't happen that often anyway.
foreach ($files as $key => $file) {
// getNormalizedFILES() removes any file with error == 4
- if ($file['error'] !== 0) {
+ if ($file['error'] !== UPLOAD_ERR_OK) {
$this->output->set_status_header(400);
+ $message = "";
+
+ // ERR_OK only for completeness, if above ignores it
$errors = array(
- 0=>"There is no error, the file uploaded with success",
- 1=>"The uploaded file exceeds the upload_max_filesize directive in php.ini",
- 2=>"The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form",
- 3=>"The uploaded file was only partially uploaded",
- 4=>"No file was uploaded",
- 6=>"Missing a temporary folder"
+ UPLOAD_ERR_OK => "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",
+ UPLOAD_ERR_NO_TMP_DIR => "Missing a temporary folder",
+ UPLOAD_ERR_CANT_WRITE => "Failed to write file to disk",
+ UPLOAD_ERR_EXTENSION => "A PHP extension stopped the file upload",
);
$this->data["msg"] = "Unknown error.";
- if (isset($file)) {
+ if (isset($errors[$file['error']])) {
$this->data["msg"] = $errors[$file['error']];
+ } else {
+ $this->data["msg"] = "Unknown error code: ".$file['error'].". Please report a bug.";
}
+
$this->load->view('header', $this->data);
$this->load->view($this->var->view_dir.'/upload_error', $this->data);
$this->load->view('footer');