diff options
Diffstat (limited to 'files/ajax/upload.php')
-rw-r--r-- | files/ajax/upload.php | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/files/ajax/upload.php b/files/ajax/upload.php index f005a8af226..041ec0c92e3 100644 --- a/files/ajax/upload.php +++ b/files/ajax/upload.php @@ -3,19 +3,13 @@ // 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" ); +OC_JSON::setContentTypeHeader('text/plain'); -// Check if we are a user -if( !OC_User::isLoggedIn()){ - echo json_encode( array( "status" => "error", "data" => array( "message" => "Authentication error" ))); - exit(); -} +OC_JSON::checkLoggedIn(); if (!isset($_FILES['files'])) { - echo json_encode( array( "status" => "error", "data" => array( "message" => "No file was uploaded. Unknown error" ))); + OC_JSON::error(array("data" => array( "message" => "No file was uploaded. Unknown error" ))); exit(); } foreach ($_FILES['files']['error'] as $error) { @@ -28,7 +22,7 @@ foreach ($_FILES['files']['error'] as $error) { 4=>$l->t("No file was uploaded"), 6=>$l->t("Missing a temporary folder") ); - echo json_encode( array( "status" => "error", "data" => array( "message" => $errors[$error] ))); + OC_JSON::error(array("data" => array( "message" => $errors[$error] ))); exit(); } } @@ -43,7 +37,7 @@ foreach($files['size'] as $size){ $totalSize+=$size; } if($totalSize>OC_Filesystem::free_space('/')){ - echo json_encode( array( "status" => "error", "data" => array( "message" => "Not enough space available" ))); + OC_JSON::error(array("data" => array( "message" => "Not enough space available" ))); exit(); } @@ -56,12 +50,12 @@ if(strpos($dir,'..') === false){ $result[]=array( "status" => "success", 'mime'=>OC_Filesystem::getMimeType($target),'size'=>OC_Filesystem::filesize($target),'name'=>$files['name'][$i]); } } - echo json_encode($result); + OC_JSON::encodedPrint($result); exit(); }else{ $error='invalid dir'; } -echo json_encode(array( 'status' => 'error', 'data' => array('error' => $error, "file" => $fileName))); +OC_JSON::error(array('data' => array('error' => $error, "file" => $fileName))); ?> |