summaryrefslogtreecommitdiff
path: root/modules/gallery/controllers/uploader.php
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2011-10-03 23:19:44 -0700
committerBharat Mediratta <bharat@menalto.com>2011-10-03 23:19:44 -0700
commite5175fd277d597acce1d824c8c82da08d15b407a (patch)
tree8e444eae5942734c2b4742c2c8e42334e8a94bf6 /modules/gallery/controllers/uploader.php
parent0a8678d0cbbb11a1544b2a0474d77ebba72c8a9b (diff)
Fix the standard and REST uploaders to use a callback function to
delete temporary files during shutdown. Fixes #1788.
Diffstat (limited to 'modules/gallery/controllers/uploader.php')
-rw-r--r--modules/gallery/controllers/uploader.php5
1 files changed, 1 insertions, 4 deletions
diff --git a/modules/gallery/controllers/uploader.php b/modules/gallery/controllers/uploader.php
index 9c2bf7d7..05b3bf7b 100644
--- a/modules/gallery/controllers/uploader.php
+++ b/modules/gallery/controllers/uploader.php
@@ -55,6 +55,7 @@ class Uploader_Controller extends Controller {
if ($form->validate() && $file_validation->validate()) {
$temp_filename = upload::save("Filedata");
+ Event::add("system.shutdown", create_function("", "unlink(\"$temp_filename\");"));
try {
$item = ORM::factory("item");
$item->name = substr(basename($temp_filename), 10); // Skip unique identifier Kohana adds
@@ -87,14 +88,10 @@ class Uploader_Controller extends Controller {
Kohana_Log::add("error", "Validation errors: " . print_r($e->validation->errors(), 1));
}
- if (file_exists($temp_filename)) {
- unlink($temp_filename);
- }
header("HTTP/1.1 500 Internal Server Error");
print "ERROR: " . $e->getMessage();
return;
}
- unlink($temp_filename);
print "FILEID: $item->id";
} else {
header("HTTP/1.1 400 Bad Request");