From 43c7b8c642a5fc8541122414849a75770975b222 Mon Sep 17 00:00:00 2001 From: Cash Costello Date: Sat, 30 Oct 2010 17:26:32 +0000 Subject: handling errors in ajax upload --- actions/ajax_upload.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'actions/ajax_upload.php') diff --git a/actions/ajax_upload.php b/actions/ajax_upload.php index 9aea9c19d..1f5588197 100644 --- a/actions/ajax_upload.php +++ b/actions/ajax_upload.php @@ -16,6 +16,7 @@ if (!$album) { // probably POST limit exceeded if (empty($_FILES)) { + echo 'Image was too large'; exit; } @@ -28,9 +29,15 @@ $temp_file = $_FILES['Image']['tmp_name']; $name = $_FILES['Image']['name']; $file_size = $_FILES['Image']['size']; +$mime = tp_upload_get_mimetype($name); +if ($mime == 'unknown') { + echo 'Not an image'; + exit; +} + $image = new TidypicsImage(); $image->container_guid = $album_guid; -$image->setMimeType(tp_upload_get_mimetype($name)); +$image->setMimeType($mime); $image->simpletype = "image"; $image->access_id = $album->access_id; $image->title = substr($name, 0, strrpos($name, '.')); @@ -50,5 +57,5 @@ if (get_plugin_setting('img_river_view', 'tidypics') === "all") { add_to_river('river/object/image/create', 'create', $image->owner_guid, $image->guid); } -echo "1"; +echo "success"; exit; \ No newline at end of file -- cgit v1.2.3