diff options
author | Bharat Mediratta <bharat@menalto.com> | 2011-10-03 23:19:44 -0700 |
---|---|---|
committer | Bharat Mediratta <bharat@menalto.com> | 2011-10-03 23:19:44 -0700 |
commit | e5175fd277d597acce1d824c8c82da08d15b407a (patch) | |
tree | 8e444eae5942734c2b4742c2c8e42334e8a94bf6 /modules | |
parent | 0a8678d0cbbb11a1544b2a0474d77ebba72c8a9b (diff) |
Fix the standard and REST uploaders to use a callback function to
delete temporary files during shutdown. Fixes #1788.
Diffstat (limited to 'modules')
-rw-r--r-- | modules/gallery/controllers/uploader.php | 5 | ||||
-rw-r--r-- | modules/rest/controllers/rest.php | 1 |
2 files changed, 2 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"); diff --git a/modules/rest/controllers/rest.php b/modules/rest/controllers/rest.php index 52d9925b..624a02a0 100644 --- a/modules/rest/controllers/rest.php +++ b/modules/rest/controllers/rest.php @@ -69,6 +69,7 @@ class Rest_Controller extends Controller { $request->params = (object) $input->post(); if (isset($_FILES["file"])) { $request->file = upload::save("file"); + Event::add("system.shutdown", create_function("", "unlink(\"{$request->file}\");")); } break; } |