rename.php 461 B

123456789101112131415161718192021
  1. <?php
  2. // Init owncloud
  3. OCP\JSON::checkLoggedIn();
  4. OCP\JSON::callCheck();
  5. // Get data
  6. $dir = stripslashes($_GET["dir"]);
  7. $file = stripslashes($_GET["file"]);
  8. $newname = stripslashes($_GET["newname"]);
  9. // Delete
  10. if( OC_Files::move( $dir, $file, $dir, $newname )) {
  11. OCP\JSON::success(array("data" => array( "dir" => $dir, "file" => $file, "newname" => $newname )));
  12. }
  13. else{
  14. OCP\JSON::error(array("data" => array( "message" => "Unable to rename file" )));
  15. }