diff options
author | Robin Appelman <icewind@owncloud.com> | 2013-01-28 21:09:18 +0100 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2013-01-28 21:09:18 +0100 |
commit | 86e5a9cd7354225572507343015107edc665aa08 (patch) | |
tree | ef883dfe31fb244027cd47c7523f35bbc00d4b12 /apps/files/ajax/upload.php | |
parent | 929b8c3e6926dbe4cf2c3e0b2eb00b502d49f64a (diff) | |
download | nextcloud-server-86e5a9cd7354225572507343015107edc665aa08.tar.gz nextcloud-server-86e5a9cd7354225572507343015107edc665aa08.zip |
Files: fix sharing newly uploaded files
Diffstat (limited to 'apps/files/ajax/upload.php')
-rw-r--r-- | apps/files/ajax/upload.php | 37 |
1 files changed, 20 insertions, 17 deletions
diff --git a/apps/files/ajax/upload.php b/apps/files/ajax/upload.php index befb94d0844..9ecc1a6c2f4 100644 --- a/apps/files/ajax/upload.php +++ b/apps/files/ajax/upload.php @@ -21,13 +21,13 @@ if (!isset($_FILES['files'])) { foreach ($_FILES['files']['error'] as $error) { if ($error != 0) { $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: ') + 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' + 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_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'), ); @@ -40,14 +40,17 @@ $files = $_FILES['files']; $dir = $_POST['dir']; $error = ''; +$maxUploadFilesize = OCP\Util::maxUploadFilesize($dir); +$maxHumanFilesize = OCP\Util::humanFileSize($maxUploadFilesize); + $totalSize = 0; foreach ($files['size'] as $size) { $totalSize += $size; } -if($totalSize>\OC\Files\Filesystem::free_space($dir)) { - OCP\JSON::error(array('data' => array( 'message' => $l->t( 'Not enough space available' ), - 'uploadMaxFilesize'=>$maxUploadFilesize, - 'maxHumanFilesize'=>$maxHumanFilesize))); +if ($totalSize > \OC\Files\Filesystem::free_space($dir)) { + OCP\JSON::error(array('data' => array('message' => $l->t('Not enough space available'), + 'uploadMaxFilesize' => $maxUploadFilesize, + 'maxHumanFilesize' => $maxHumanFilesize))); exit(); } @@ -58,18 +61,18 @@ if (strpos($dir, '..') === false) { $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\Files\Filesystem::normalizePath($target); - if(is_uploaded_file($files['tmp_name'][$i]) and \OC\Files\Filesystem::fromTmpFile($files['tmp_name'][$i], $target)) { + if (is_uploaded_file($files['tmp_name'][$i]) and \OC\Files\Filesystem::fromTmpFile($files['tmp_name'][$i], $target)) { $meta = \OC\Files\Filesystem::getFileInfo($target); // updated max file size after upload $storageStats = \OCA\files\lib\Helper::buildFileStorageStatistics($dir); - $result[]=array( 'status' => 'success', - 'mime'=>$meta['mimetype'], - 'size'=>$meta['size'], - 'id'=>$id, - 'name'=>basename($target), - 'uploadMaxFilesize'=>$maxUploadFilesize, - 'maxHumanFilesize'=>$maxHumanFilesize + $result[] = array('status' => 'success', + 'mime' => $meta['mimetype'], + 'size' => $meta['size'], + 'id' => $meta['fileid'], + 'name' => basename($target), + 'uploadMaxFilesize' => $maxUploadFilesize, + 'maxHumanFilesize' => $maxHumanFilesize ); } } |