aboutsummaryrefslogtreecommitdiff
path: root/actions
diff options
context:
space:
mode:
authorCash Costello <cash.costello@gmail.com>2009-05-16 17:46:09 +0000
committerCash Costello <cash.costello@gmail.com>2009-05-16 17:46:09 +0000
commit4b63b8ad8df01c077d918e2cbe65e0818f971d69 (patch)
tree75b61de7af926094ce3b327008f109f9a031d9e4 /actions
parentcd3b1df0db7644a4e8e779ac91584bf4ae722ace (diff)
downloadelgg-4b63b8ad8df01c077d918e2cbe65e0818f971d69.tar.gz
elgg-4b63b8ad8df01c077d918e2cbe65e0818f971d69.tar.bz2
added check for no images uploaded
Diffstat (limited to 'actions')
-rw-r--r--actions/upload.php24
1 files changed, 21 insertions, 3 deletions
diff --git a/actions/upload.php b/actions/upload.php
index eeb68aba1..3357fe469 100644
--- a/actions/upload.php
+++ b/actions/upload.php
@@ -7,21 +7,39 @@
global $CONFIG;
require_once(dirname(__FILE__)."/resize.php");
-
+
// Get common variables
$access_id = (int) get_input("access_id");
$container_guid = (int) get_input('container_guid', 0);
if (!$container_guid)
$container_guid == $_SESSION['user']->getGUID();
-
+
$not_uploaded = array();
- $uploaded_images = array();
+ $uploaded_images = array();
+
+ // test to make sure at least 1 image was selected by user
+ $num_images = 0;
+ foreach($_FILES as $key => $sent_file) {
+ if (!empty($sent_file['name']))
+ $num_images++;
+ }
+ if ($num_images == 0) {
+ // have user try again
+ register_error('No images were selected. Please try again');
+ forward(get_input('forward_url', $_SERVER['HTTP_REFERER']));
+ }
+
foreach($_FILES as $key => $sent_file) {
if (!empty($sent_file['name'])) {
$name = $_FILES[$key]['name'];
$mime = $_FILES[$key]['type'];
+ //error_log('Name ' . $sent_file['name']);
+ //error_log('MIME ' . $sent_file['type']);
+ //error_log('error ' . $sent_file['error']);
+ //error_log('Size ' . $sent_file['size']);
+
//make sure file is an image
if ($mime == 'image/jpeg' || $mime == 'image/gif' || $mime == 'image/png' || $mime == 'image/pjpeg') {
//this will save to users folder in /image/ and organize by photo album