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();
|
|
|
|
}
|
|
|
|
|
|
|
|
$fileName=$_FILES['file']['name'];
|
|
|
|
$source=$_FILES['file']['tmp_name'];
|
|
|
|
$dir = $_POST['dir'];
|
|
|
|
if(!empty($dir)) $dir .= '/';
|
|
|
|
$target='/' . stripslashes($dir) . $fileName;
|
2011-04-17 13:27:28 +04:00
|
|
|
if(strpos($dir,'..') === false){
|
2011-04-17 03:17:34 +04:00
|
|
|
if(OC_FILESYSTEM::fromUploadedFile($source,$target)){
|
2011-04-17 01:18:06 +04:00
|
|
|
echo json_encode(array( "status" => "success"));
|
|
|
|
exit();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-17 01:28:50 +04:00
|
|
|
$error = $_FILES['file']['error'];
|
|
|
|
|
|
|
|
echo json_encode(array( 'status' => 'error', 'data' => array('error' => $error)));
|
2011-04-17 01:18:06 +04:00
|
|
|
|
|
|
|
?>
|