newfolder.php 684 B

123456789101112131415161718192021222324252627
  1. <?php
  2. // Init owncloud
  3. OCP\JSON::checkLoggedIn();
  4. // Get the params
  5. $dir = isset( $_POST['dir'] ) ? stripslashes($_POST['dir']) : '';
  6. $foldername = isset( $_POST['foldername'] ) ? stripslashes($_POST['foldername']) : '';
  7. if(trim($foldername) == '') {
  8. OCP\JSON::error(array("data" => array( "message" => "Empty Foldername" )));
  9. exit();
  10. }
  11. if(strpos($foldername,'/')!==false){
  12. OCP\JSON::error(array("data" => array( "message" => "Invalid Foldername" )));
  13. exit();
  14. }
  15. if(OC_Files::newFile($dir, stripslashes($foldername), 'dir')) {
  16. OCP\JSON::success(array("data" => array()));
  17. exit();
  18. }
  19. OCP\JSON::error(array("data" => array( "message" => "Error when creating the folder" )));