aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--actions/ajax_upload.php11
-rw-r--r--lib/upload.php7
-rw-r--r--views/default/tidypics/forms/ajax_upload.php8
3 files changed, 19 insertions, 7 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
diff --git a/lib/upload.php b/lib/upload.php
index ac926403d..30540dced 100644
--- a/lib/upload.php
+++ b/lib/upload.php
@@ -11,7 +11,7 @@
*/
function tp_upload_get_mimetype($originalName) {
$extension = substr(strrchr($originalName, '.'), 1);
- switch ($extension) {
+ switch (strtolower($extension)) {
case 'png':
return 'image/png';
break;
@@ -19,9 +19,12 @@ function tp_upload_get_mimetype($originalName) {
return 'image/gif';
break;
case 'jpg':
- default:
+ case 'jpeg':
return 'image/jpeg';
break;
+ default:
+ return 'unknown';
+ break;
}
}
diff --git a/views/default/tidypics/forms/ajax_upload.php b/views/default/tidypics/forms/ajax_upload.php
index 87a6ad0ed..47aa954c7 100644
--- a/views/default/tidypics/forms/ajax_upload.php
+++ b/views/default/tidypics/forms/ajax_upload.php
@@ -83,8 +83,6 @@ $("#uploadify").uploadify({
'cancelImg' : '<?php echo $vars['url']; ?>_graphics/icon_customise_remove.gif',
'multi' : true,
'auto' : false,
- 'fileDesc' : '<?php echo elgg_echo('tidypics:uploader:filedesc'); ?>',
- 'fileExt' : '*.jpg;*.jpeg;*.png;*.gif',
'wmode' : 'transparent',
'buttonImg' : " ",
'height' : 20,
@@ -117,8 +115,12 @@ $("#uploadify").uploadify({
}
);
},
- 'onComplete' : function(event, queueID) {
+ 'onComplete' : function(event, queueID, fileObj, response) {
// check for errors here
+ if (response != 'success') {
+ $("#uploadify" + queueID + " .percentage").text(" - " + response);
+ $("#uploadify" + queueID).addClass('uploadifyError');
+ }
$("#uploadify" + queueID + " > .cancel").remove();
return false;
},