aboutsummaryrefslogtreecommitdiff
path: root/actions/photos/image/ajax_upload.php
diff options
context:
space:
mode:
authorBrett Profitt <brett.profitt@gmail.com>2012-03-16 22:51:12 -0700
committerBrett Profitt <brett.profitt@gmail.com>2012-03-16 22:51:12 -0700
commit5cc8de829c0a7b86c8df27293f4825d0e340d592 (patch)
tree62b71d96d02fce3a75393da08219714fdad4789d /actions/photos/image/ajax_upload.php
parente6e33ca1a7afb00a855f57df5a5263674b23c93c (diff)
downloadelgg-5cc8de829c0a7b86c8df27293f4825d0e340d592.tar.gz
elgg-5cc8de829c0a7b86c8df27293f4825d0e340d592.tar.bz2
Fixes #14. Fixed uploadify.
Diffstat (limited to 'actions/photos/image/ajax_upload.php')
-rw-r--r--actions/photos/image/ajax_upload.php57
1 files changed, 57 insertions, 0 deletions
diff --git a/actions/photos/image/ajax_upload.php b/actions/photos/image/ajax_upload.php
new file mode 100644
index 000000000..d6b083cf6
--- /dev/null
+++ b/actions/photos/image/ajax_upload.php
@@ -0,0 +1,57 @@
+<?php
+/**
+ * Elgg single upload action for flash/ajax uploaders
+ */
+
+elgg_load_library('tidypics:upload');
+
+$album_guid = (int) get_input('album_guid');
+$file_var_name = get_input('file_var_name', 'Image');
+$batch = get_input('batch');
+
+$album = get_entity($album_guid);
+if (!$album) {
+ echo elgg_echo('tidypics:baduploadform');
+ exit;
+}
+
+// probably POST limit exceeded
+if (empty($_FILES)) {
+ trigger_error('Tidypics warning: user exceeded post limit on image upload', E_USER_WARNING);
+ register_error(elgg_echo('tidypics:exceedpostlimit'));
+ exit;
+}
+
+$file = $_FILES['Image'];
+
+$mime = tp_upload_get_mimetype($file['name']);
+if ($mime == 'unknown') {
+ echo 'Not an image';
+ exit;
+}
+
+// we have to override the mime type because uploadify sends everything as application/octet-string
+$file['type'] = $mime;
+
+$image = new TidypicsImage();
+$image->container_guid = $album->getGUID();
+$image->setMimeType($mime);
+$image->access_id = $album->access_id;
+$image->batch = $batch;
+
+try {
+ $image->save($file);
+ $album->prependImageList(array($image->guid));
+
+ if (elgg_get_plugin_setting('img_river_view', 'tidypics') === "all") {
+ add_to_river('river/object/image/create', 'create', $image->getObjectOwnerGUID(), $image->getGUID());
+ }
+
+ echo elgg_echo('success');
+} catch (Exception $e) {
+ // remove the bits that were saved
+ $image->delete();
+ echo $e->getMessage();
+}
+
+exit; \ No newline at end of file