diff options
author | Florian Pritz <bluewind@server-speed.net> | 2011-06-04 08:55:25 +0200 |
---|---|---|
committer | Florian Pritz <bluewind@server-speed.net> | 2011-06-04 08:55:25 +0200 |
commit | 844031a6ab7d5fc035f350ee4b260f6cc73bdb76 (patch) | |
tree | a3073287e5f9b463871a017e3dec3160f6de8065 /application | |
parent | a40c3b44652ed3cfe0f2f6243a735bdb80714b2e (diff) |
simplify do_paste and return correct status codes
Signed-off-by: Florian Pritz <bluewind@server-speed.net>
Diffstat (limited to 'application')
-rw-r--r-- | application/controllers/file.php | 11 | ||||
-rw-r--r-- | application/views/file/upload_error.php | 4 | ||||
-rw-r--r-- | application/views/file_plaintext/upload_error.php | 2 |
3 files changed, 7 insertions, 10 deletions
diff --git a/application/controllers/file.php b/application/controllers/file.php index 351be6ae5..ad70eeef9 100644 --- a/application/controllers/file.php +++ b/application/controllers/file.php @@ -163,20 +163,17 @@ class File extends CI_Controller { { $data = array(); $extension = $this->input->post('extension'); - // TODO: Display nice error for cli clients - if(!isset($_FILES['file'])) { + if(!isset($_FILES['file']) || $_FILES['file']['error'] !== 0) { + $this->output->set_status_header(400); $this->load->view($this->var->view_dir.'/header', $data); $this->load->view($this->var->view_dir.'/upload_error'); $this->load->view($this->var->view_dir.'/footer'); return; } - if ($_FILES['file']['error'] !== 0) { - $this->upload_form(); - return; - } + $filesize = filesize($_FILES['file']['tmp_name']); - // TODO: Display nice error for cli clients if ($filesize > $this->config->item('upload_max_size')) { + $this->output->set_status_header(413); $this->load->view($this->var->view_dir.'/header', $data); $this->load->view($this->var->view_dir.'/too_big'); $this->load->view($this->var->view_dir.'/footer'); diff --git a/application/views/file/upload_error.php b/application/views/file/upload_error.php index e757b58c1..606110d83 100644 --- a/application/views/file/upload_error.php +++ b/application/views/file/upload_error.php @@ -1,6 +1,6 @@ <div style="text-align:center"> <p> - An error occured while uploading.<br /> - Most likely your file is too big. + An error occurred while uploading.<br /> + Most likely your file is too big or has not been uploaded completely. </p> </div> diff --git a/application/views/file_plaintext/upload_error.php b/application/views/file_plaintext/upload_error.php index 8386b871b..c1482de27 100644 --- a/application/views/file_plaintext/upload_error.php +++ b/application/views/file_plaintext/upload_error.php @@ -1,2 +1,2 @@ -An error occured while uploading. Most likely your file is too big. +An error occurred while uploading. Most likely your file is too big or has not been uploaded completely. |