summaryrefslogtreecommitdiffstats
path: root/apps/files/ajax
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2012-12-02 03:03:48 +0100
committerRobin Appelman <icewind@owncloud.com>2012-12-02 03:03:48 +0100
commit72b6faa69d693fa0d2a21d592b6ae36023757872 (patch)
tree9e6c31b6edc5715c34849c737f6f32ff6dcedf8a /apps/files/ajax
parent702444b2422326388e494091e815fd3d9b03cc87 (diff)
parent401c56ce7bda6b8fb782e3cea962e47546626eef (diff)
downloadnextcloud-server-72b6faa69d693fa0d2a21d592b6ae36023757872.tar.gz
nextcloud-server-72b6faa69d693fa0d2a21d592b6ae36023757872.zip
merge master into filesystem
Diffstat (limited to 'apps/files/ajax')
-rw-r--r--apps/files/ajax/upload.php33
1 files changed, 19 insertions, 14 deletions
diff --git a/apps/files/ajax/upload.php b/apps/files/ajax/upload.php
index c89ce762df8..f40679f5756 100644
--- a/apps/files/ajax/upload.php
+++ b/apps/files/ajax/upload.php
@@ -10,22 +10,24 @@ OCP\JSON::checkLoggedIn();
OCP\JSON::callCheck();
if (!isset($_FILES['files'])) {
- OCP\JSON::error(array("data" => array( "message" => "No file was uploaded. Unknown error" )));
+ OCP\JSON::error(array('data' => array( 'message' => 'No file was uploaded. Unknown error' )));
exit();
}
foreach ($_FILES['files']['error'] as $error) {
if ($error != 0) {
$l=OC_L10N::get('files');
$errors = array(
- UPLOAD_ERR_OK=>$l->t("There is no error, the file uploaded with success"),
- UPLOAD_ERR_INI_SIZE=>$l->t("The uploaded file exceeds the upload_max_filesize directive in php.ini").ini_get('upload_max_filesize'),
- UPLOAD_ERR_FORM_SIZE=>$l->t("The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form"),
- UPLOAD_ERR_PARTIAL=>$l->t("The uploaded file was only partially uploaded"),
- UPLOAD_ERR_NO_FILE=>$l->t("No file was uploaded"),
- UPLOAD_ERR_NO_TMP_DIR=>$l->t("Missing a temporary folder"),
+ UPLOAD_ERR_OK=>$l->t('There is no error, the file uploaded with success'),
+ UPLOAD_ERR_INI_SIZE=>$l->t('The uploaded file exceeds the upload_max_filesize directive in php.ini: ')
+ .ini_get('upload_max_filesize'),
+ UPLOAD_ERR_FORM_SIZE=>$l->t('The uploaded file exceeds the MAX_FILE_SIZE directive that was specified'
+ .' in the HTML form'),
+ UPLOAD_ERR_PARTIAL=>$l->t('The uploaded file was only partially uploaded'),
+ UPLOAD_ERR_NO_FILE=>$l->t('No file was uploaded'),
+ UPLOAD_ERR_NO_TMP_DIR=>$l->t('Missing a temporary folder'),
UPLOAD_ERR_CANT_WRITE=>$l->t('Failed to write to disk'),
);
- OCP\JSON::error(array("data" => array( "message" => $errors[$error] )));
+ OCP\JSON::error(array('data' => array( 'message' => $errors[$error] )));
exit();
}
}
@@ -38,8 +40,8 @@ $totalSize=0;
foreach($files['size'] as $size) {
$totalSize+=$size;
}
-if($totalSize > \OC\Files\Filesystem::free_space($dir)) {
- OCP\JSON::error(array("data" => array( "message" => "Not enough space available" )));
+if($totalSize>\OC\Files\Filesystem::free_space($dir)) {
+ OCP\JSON::error(array('data' => array( 'message' => 'Not enough space available' )));
exit();
}
@@ -47,13 +49,16 @@ $result=array();
if(strpos($dir, '..') === false) {
$fileCount=count($files['name']);
for($i=0;$i<$fileCount;$i++) {
- $target = OCP\Files::buildNotExistingFileName(stripslashes($dir), $files['name'][$i]);
+ $target = OCP\Files::buildNotExistingFileName(stripslashes($dir), $files['name'][$i]);
// $path needs to be normalized - this failed within drag'n'drop upload to a sub-folder
$target = OC_Filesystem::normalizePath($target);
if(is_uploaded_file($files['tmp_name'][$i]) and OC_Filesystem::fromTmpFile($files['tmp_name'][$i], $target)) {
$meta = \OC\Files\Filesystem::getFileInfo($target);
- $id = $meta['fileid'];
- $result[]=array( "status" => "success", 'mime'=>$meta['mimetype'], 'size'=>$meta['size'], 'id'=>$id, 'name'=>basename($target));
+ $result[]=array( 'status' => 'success',
+ 'mime'=>$meta['mimetype'],
+ 'size'=>$meta['size'],
+ 'id'=>$meta['fileid'],
+ 'name'=>basename($target));
}
}
OCP\JSON::encodedPrint($result);
@@ -62,4 +67,4 @@ if(strpos($dir, '..') === false) {
$error='invalid dir';
}
-OCP\JSON::error(array('data' => array('error' => $error, "file" => $fileName)));
+OCP\JSON::error(array('data' => array('error' => $error, 'file' => $fileName)));