nextcloud/apps/files/ajax/move.php

25 lines
619 B
PHP
Raw Normal View History

<?php
// Init owncloud
2012-05-03 14:23:29 +04:00
OCP\JSON::checkLoggedIn();
2012-07-07 17:58:11 +04:00
OCP\JSON::callCheck();
// Get data
$dir = stripslashes($_GET["dir"]);
$file = stripslashes($_GET["file"]);
2012-10-24 17:37:32 +04:00
$target = stripslashes(urldecode($_GET["target"]));
if(OC_Filesystem::file_exists($target . '/' . $file)){
OCP\JSON::error(array("data" => array( "message" => "Could not move $file - File with this name already exists" )));
exit;
}
2012-08-29 02:50:12 +04:00
if(OC_Files::move($dir, $file, $target, $file)) {
2012-05-03 14:23:29 +04:00
OCP\JSON::success(array("data" => array( "dir" => $dir, "files" => $file )));
2012-08-29 02:50:12 +04:00
} else {
2012-05-03 14:23:29 +04:00
OCP\JSON::error(array("data" => array( "message" => "Could not move $file" )));
}