server/files/ajax/newfolder.php
Florian Pritz 8648e3c43c only call error_log() if DEBUG is true
Signed-off-by: Florian Pritz <bluewind@xinu.at>
2011-09-24 18:41:47 +02:00

29 lines
No EOL
918 B
PHP

<?php
// Init owncloud
require_once('../../lib/base.php');
// We send json data
header( "Content-Type: application/jsonrequest" );
// Check if we are a user
if( !OC_User::isLoggedIn()){
echo json_encode( array( "status" => "error", "data" => array( "message" => "Authentication error" )));
exit();
}
// Get the params
$dir = isset( $_GET['dir'] ) ? $_GET['dir'] : '';
$foldername = isset( $_GET['foldername'] ) ? $_GET['foldername'] : '';
if($foldername == '') {
echo json_encode( array( "status" => "error", "data" => array( "message" => "Empty Foldername" )));
exit();
}
if(defined("DEBUG") && DEBUG) {error_log('try to create ' . $foldername . ' in ' . $dir);}
if(OC_Files::newFile($dir, $foldername, 'dir')) {
echo json_encode( array( "status" => "success", "data" => array()));
exit();
}
echo json_encode( array( "status" => "error", "data" => array( "message" => "Error when creating the folder" )));