2011-04-17 01:18:06 +04:00
|
|
|
<?php
|
|
|
|
|
|
|
|
// Init owncloud
|
|
|
|
require_once('../../lib/base.php');
|
|
|
|
|
|
|
|
// We send json data
|
|
|
|
// header( "Content-Type: application/json" );
|
|
|
|
// Firefox and Konqueror tries to download application/json for me. --Arthur
|
|
|
|
header( "Content-Type: text/plain" );
|
|
|
|
|
|
|
|
// Check if we are a user
|
|
|
|
if( !OC_USER::isLoggedIn()){
|
2011-04-18 17:07:14 +04:00
|
|
|
echo json_encode( array( "status" => "error", "data" => array( "message" => "Authentication error" )));
|
2011-04-17 01:18:06 +04:00
|
|
|
exit();
|
|
|
|
}
|
|
|
|
|
2011-07-19 22:23:33 +04:00
|
|
|
$files=$_FILES['files'];
|
|
|
|
|
2011-04-17 01:18:06 +04:00
|
|
|
$dir = $_POST['dir'];
|
|
|
|
if(!empty($dir)) $dir .= '/';
|
2011-07-19 22:23:33 +04:00
|
|
|
$error='';
|
|
|
|
$result=array();
|
2011-04-17 13:27:28 +04:00
|
|
|
if(strpos($dir,'..') === false){
|
2011-07-19 22:23:33 +04:00
|
|
|
$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]);
|
|
|
|
}
|
2011-04-17 01:18:06 +04:00
|
|
|
}
|
2011-07-19 22:23:33 +04:00
|
|
|
echo json_encode($result);
|
|
|
|
exit();
|
|
|
|
}else{
|
|
|
|
$error='invalid dir';
|
2011-04-17 01:18:06 +04:00
|
|
|
}
|
|
|
|
|
2011-04-19 11:13:50 +04:00
|
|
|
echo json_encode(array( 'status' => 'error', 'data' => array('error' => $error, "file" => $fileName)));
|
2011-04-17 01:18:06 +04:00
|
|
|
|
|
|
|
?>
|