server/files/ajax/newfolder.php

29 lines
918 B
PHP
Raw Normal View History

2011-04-17 15:49:56 +00:00
<?php
// Init owncloud
require_once('../../lib/base.php');
// We send json data
header( "Content-Type: application/jsonrequest" );
// Check if we are a user
2011-07-29 19:36:03 +00:00
if( !OC_User::isLoggedIn()){
2011-04-17 15:49:56 +00:00
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);}
2011-07-29 19:36:03 +00:00
if(OC_Files::newFile($dir, $foldername, 'dir')) {
2011-04-17 15:49:56 +00:00
echo json_encode( array( "status" => "success", "data" => array()));
exit();
}
echo json_encode( array( "status" => "error", "data" => array( "message" => "Error when creating the folder" )));