2011-04-16 21:18:06 +00: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 13:07:14 +00:00
|
|
|
echo json_encode( array( "status" => "error", "data" => array( "message" => "Authentication error" )));
|
2011-04-16 21:18:06 +00:00
|
|
|
exit();
|
|
|
|
}
|
|
|
|
|
|
|
|
$fileName=$_FILES['file']['name'];
|
|
|
|
$source=$_FILES['file']['tmp_name'];
|
|
|
|
$dir = $_POST['dir'];
|
|
|
|
if(!empty($dir)) $dir .= '/';
|
|
|
|
$target='/' . stripslashes($dir) . $fileName;
|
2011-04-17 09:27:28 +00:00
|
|
|
if(strpos($dir,'..') === false){
|
2011-04-16 23:17:34 +00:00
|
|
|
if(OC_FILESYSTEM::fromUploadedFile($source,$target)){
|
2011-06-04 20:59:18 +00:00
|
|
|
echo json_encode(array( "status" => "success", 'mime'=>OC_FILESYSTEM::getMimeType($target),'size'=>OC_FILESYSTEM::filesize($target)));
|
2011-04-16 21:18:06 +00:00
|
|
|
exit();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-16 21:28:50 +00:00
|
|
|
$error = $_FILES['file']['error'];
|
|
|
|
|
2011-04-19 07:13:50 +00:00
|
|
|
echo json_encode(array( 'status' => 'error', 'data' => array('error' => $error, "file" => $fileName)));
|
2011-04-16 21:18:06 +00:00
|
|
|
|
|
|
|
?>
|