nextcloud/apps/files/ajax/move.php

26 lines
685 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"]);
$target = stripslashes(rawurldecode($_GET["target"]));
2013-01-09 15:48:57 +04:00
$l=OC_L10N::get('files');
if(OC_Filesystem::file_exists($target . '/' . $file)) {
2013-01-09 15:48:57 +04:00
OCP\JSON::error(array("data" => array( "message" => $l->t("Could not move %s - File with this name already exists", array($file)) )));
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 {
2013-01-09 15:48:57 +04:00
OCP\JSON::error(array("data" => array( "message" => $l->t("Could not move %s", array($file)) )));
}