aboutsummaryrefslogtreecommitdiffstats
path: root/files/ajax/upload.php
diff options
context:
space:
mode:
authorRobin Appelman <icewind1991@gmail.com>2011-07-19 20:23:33 +0200
committerRobin Appelman <icewind1991@gmail.com>2011-07-19 20:23:33 +0200
commitb69ae10b7423b1753f15bd16e0ae9c8ca5d157e4 (patch)
tree914182a1333ee940f9538cd67a941bec193e3c05 /files/ajax/upload.php
parent24e81ce4d58f08e317846d10e1ca3aecb747775d (diff)
downloadnextcloud-server-b69ae10b7423b1753f15bd16e0ae9c8ca5d157e4.tar.gz
nextcloud-server-b69ae10b7423b1753f15bd16e0ae9c8ca5d157e4.zip
Provide ability to select mutliply files during upload for browsers that support it.
Diffstat (limited to 'files/ajax/upload.php')
-rw-r--r--files/ajax/upload.php22
1 files changed, 14 insertions, 8 deletions
diff --git a/files/ajax/upload.php b/files/ajax/upload.php
index effee0c03c1..f47f9b3d282 100644
--- a/files/ajax/upload.php
+++ b/files/ajax/upload.php
@@ -14,20 +14,26 @@ if( !OC_USER::isLoggedIn()){
exit();
}
-$fileName=$_FILES['file']['name'];
-$source=$_FILES['file']['tmp_name'];
+$files=$_FILES['files'];
+
$dir = $_POST['dir'];
if(!empty($dir)) $dir .= '/';
-$target='/' . stripslashes($dir) . $fileName;
+$error='';
+$result=array();
if(strpos($dir,'..') === false){
- if(OC_FILESYSTEM::fromUploadedFile($source,$target)){
- echo json_encode(array( "status" => "success", 'mime'=>OC_FILESYSTEM::getMimeType($target),'size'=>OC_FILESYSTEM::filesize($target)));
- exit();
+ $fileCount=count($files['name']);
+ for($i=0;$i<$fileCount;$i++){
+ $target='/' . stripslashes($dir) . $files['name'][$i];
+ if(OC_FILESYSTEM::fromUploadedFile($files['tmp_name'][$i],$target)){
+ $result[]=array( "status" => "success", 'mime'=>OC_FILESYSTEM::getMimeType($target),'size'=>OC_FILESYSTEM::filesize($target),'name'=>$files['name'][$i]);
+ }
}
+ echo json_encode($result);
+ exit();
+}else{
+ $error='invalid dir';
}
-$error = $_FILES['file']['error'];
-
echo json_encode(array( 'status' => 'error', 'data' => array('error' => $error, "file" => $fileName)));
?>