diff options
author | Cash Costello <cash.costello@gmail.com> | 2010-10-30 17:26:32 +0000 |
---|---|---|
committer | Cash Costello <cash.costello@gmail.com> | 2010-10-30 17:26:32 +0000 |
commit | 43c7b8c642a5fc8541122414849a75770975b222 (patch) | |
tree | b093542d2af686565262884aceec9658f7645c7d /actions | |
parent | 6cc8f7714561a681428c2d402b15666e8e0af0fd (diff) | |
download | elgg-43c7b8c642a5fc8541122414849a75770975b222.tar.gz elgg-43c7b8c642a5fc8541122414849a75770975b222.tar.bz2 |
handling errors in ajax upload
Diffstat (limited to 'actions')
-rw-r--r-- | actions/ajax_upload.php | 11 |
1 files changed, 9 insertions, 2 deletions
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 |