aboutsummaryrefslogtreecommitdiff
path: root/mod/file/actions
diff options
context:
space:
mode:
authorBrett Profitt <brett.profitt@gmail.com>2011-08-25 10:00:38 -0700
committerBrett Profitt <brett.profitt@gmail.com>2011-08-25 10:00:38 -0700
commitdccc333c765bb28da55b4a55d9c916acdb88413a (patch)
treebdd26a0b4cd85241a19b7fcb2c0770f0ac3eb9f0 /mod/file/actions
parentec7b94a64aef23b85866ecdac8e8acc712d29bb6 (diff)
parent003cb81c7888f4d2fd763e5814027c6f8d71186f (diff)
downloadelgg-dccc333c765bb28da55b4a55d9c916acdb88413a.tar.gz
elgg-dccc333c765bb28da55b4a55d9c916acdb88413a.tar.bz2
Merge branch 'master' of github.com:brettp/Elgg
Diffstat (limited to 'mod/file/actions')
-rw-r--r--mod/file/actions/file/upload.php56
1 files changed, 12 insertions, 44 deletions
diff --git a/mod/file/actions/file/upload.php b/mod/file/actions/file/upload.php
index 5d5c28bee..88a01745d 100644
--- a/mod/file/actions/file/upload.php
+++ b/mod/file/actions/file/upload.php
@@ -13,8 +13,6 @@ $container_guid = (int) get_input('container_guid', 0);
$guid = (int) get_input('file_guid');
$tags = get_input("tags");
-$ajax = get_input('ajax', FALSE);
-
if ($container_guid == 0) {
$container_guid = elgg_get_logged_in_user_guid();
}
@@ -33,17 +31,8 @@ if ($new_file) {
if (empty($_FILES['upload']['name'])) {
$error = elgg_echo('file:nofile');
-
- if ($ajax) {
- echo json_encode(array(
- 'status' => 'error',
- 'message' => $error
- ));
- exit;
- } else {
- register_error($error);
- forward(REFERER);
- }
+ register_error($error);
+ forward(REFERER);
}
$file = new FilePluginFile();
@@ -106,9 +95,10 @@ if (isset($_FILES['upload']['name']) && !empty($_FILES['upload']['name'])) {
$file->originalfilename = $_FILES['upload']['name'];
$file->simpletype = file_get_simple_type($_FILES['upload']['type']);
+ // Open the file to guarantee the directory exists
$file->open("write");
- $file->write(get_uploaded_file('upload'));
$file->close();
+ move_uploaded_file($_FILES['upload']['tmp_name'], $file->getFilenameOnFilestore());
$guid = $file->save();
@@ -158,44 +148,22 @@ elgg_clear_sticky_form('file');
// handle results differently for new files and file updates
-// ajax is only for new files from embed right now.
if ($new_file) {
if ($guid) {
$message = elgg_echo("file:saved");
- if ($ajax) {
- echo json_encode(array(
- 'status' => 'success',
- 'message' => $message
- ));
- exit;
-
- } else {
- system_message($message);
- add_to_river('river/object/file/create', 'create', elgg_get_logged_in_user_guid(), $file->guid);
- }
+ system_message($message);
+ add_to_river('river/object/file/create', 'create', elgg_get_logged_in_user_guid(), $file->guid);
} else {
// failed to save file object - nothing we can do about this
$error = elgg_echo("file:uploadfailed");
-
- if ($ajax) {
- echo json_encode(array(
- 'status' => 'error',
- 'message' => $error
- ));
- exit;
-
- } else {
- register_error($error);
- }
+ register_error($error);
}
- if (!$ajax) {
- $container = get_entity($container_guid);
- if (elgg_instanceof($container, 'group')) {
- forward("file/group/$container->guid/all");
- } else {
- forward("file/owner/$container->username");
- }
+ $container = get_entity($container_guid);
+ if (elgg_instanceof($container, 'group')) {
+ forward("file/group/$container->guid/all");
+ } else {
+ forward("file/owner/$container->username");
}
} else {