nextcloud/files/ajax/newfolder.php

29 lines
886 B
PHP
Raw Normal View History

2011-04-17 19:49:56 +04: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 23:36:03 +04:00
if( !OC_User::isLoggedIn()){
2011-04-17 19:49:56 +04: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();
}
error_log('try to create ' . $foldername . ' in ' . $dir);
2011-07-29 23:36:03 +04:00
if(OC_Files::newFile($dir, $foldername, 'dir')) {
2011-04-17 19:49:56 +04:00
echo json_encode( array( "status" => "success", "data" => array()));
exit();
}
echo json_encode( array( "status" => "error", "data" => array( "message" => "Error when creating the folder" )));