本文整理汇总了PHP中FileManager::move方法的典型用法代码示例。如果您正苦于以下问题:PHP FileManager::move方法的具体用法?PHP FileManager::move怎么用?PHP FileManager::move使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileManager
的用法示例。
在下文中一共展示了FileManager::move方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: moveFile
/**
* Move file to the other path.
*
* @access public
* @param string $sPath
* @return File
* @since 2.36.4-dev, 2015-07-03
* @version 2.37.0-dev, 2015-07-28
*/
public function moveFile($sPath)
{
\FileManager::prepareDir($sPath);
$oFileManager = new \FileManager();
$oFileManager->prepareFileByPath($this->getPath() . '/' . $this->getNameWithExt());
$oFileManager->move($sPath);
$this->setName($oFileManager->getName());
// if file name was changed in \FileManager class
$this->setPath($oFileManager->getPath());
return $this;
}
示例2: Exception
$list = array_map(function ($item) {
$date = new \DateTime('now');
$item['date'] = $date->format('Y-m-d H:i:s');
return $item;
}, $list);
$oResponse->setData($list);
$oResponse->flushJson();
}
if (Request::getApiParam('mode') === 'editfile') {
$oResponse->setData($oFtp->getContent(Request::getApiParam('path')));
$oResponse->flushJson();
}
if (Request::getApiParam('mode') === 'rename') {
$path = Request::getApiParam('path');
$newPath = Request::getApiParam('newPath');
$result = $oFtp->move($path, $newPath);
if (!$result) {
throw new Exception("Unknown error renaming this folder");
}
$oResponse->setData($result);
$oResponse->flushJson();
}
if (Request::getApiParam('mode') === 'delete') {
$path = Request::getApiParam('path');
$result = $oFtp->delete($path);
if (!$result) {
throw new Exception("Unknown error removing this item");
}
$oResponse->setData($result);
$oResponse->flushJson();
}
示例3: api_not_allowed
}
}
if (api_is_coach()) {
if (!DocumentManager::is_visible_by_id($_POST['move_file'], $_course, api_get_session_id(), api_get_user_id())) {
api_not_allowed();
}
}
$document_to_move = DocumentManager::get_document_data_by_id($_POST['move_file'], api_get_course_id());
// Security fix: make sure they can't move files that are not in the document table
if (!empty($document_to_move)) {
$real_path_target = $base_work_dir . $_POST['move_to'] . '/' . basename($document_to_move['path']);
$fileExist = false;
if (file_exists($real_path_target)) {
$fileExist = true;
}
if (FileManager::move($base_work_dir . $document_to_move['path'], $base_work_dir . $_POST['move_to'])) {
//if (1) {
//$contents = DocumentManager::replace_urls_inside_content_html_when_moving_file(basename($document_to_move['path']), $base_work_dir.dirname($document_to_move['path']), $base_work_dir.$_POST['move_to']);
//exit;
FileManager::update_db_info('update', $document_to_move['path'], $_POST['move_to'] . '/' . basename($document_to_move['path']));
//update database item property
$doc_id = $_POST['move_file'];
if (is_dir($real_path_target)) {
api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'FolderMoved', api_get_user_id(), $to_group_id, null, null, null, $session_id);
Display::display_confirmation_message(get_lang('DirMv'));
} elseif (is_file($real_path_target)) {
api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'DocumentMoved', api_get_user_id(), $to_group_id, null, null, null, $session_id);
Display::display_confirmation_message(get_lang('DocMv'));
}
// Set the current path
$curdirpath = $_POST['move_to'];
示例4: test_move
function test_move()
{
FileManager::touch('move_test.txt');
$this->assertTrue(file_exists('files/move_test.txt'));
$res = FileManager::move('move_test.txt', 'design');
$this->assertTrue($res);
$this->assertFalse(file_exists('files/move_test.txt'));
$this->assertTrue(file_exists('files/design/move_test.txt'));
$res = FileManager::move('design/move_test.txt', '..');
$this->assertFalse($res);
$this->assertEquals('Invalid folder', FileManager::error());
$res = FileManager::move('design/move_test.txt', '');
$this->assertTrue($res);
$this->assertTrue(file_exists('files/move_test.txt'));
$this->assertFalse(file_exists('files/design/move_test.txt'));
FileManager::unlink('move_test.txt');
}
示例5: Exception
$list = array_map(function ($item) {
$date = new \DateTime('now');
$item['date'] = $date->format('Y-m-d H:i:s');
return $item;
}, $list);
$oResponse->setData($list);
$oResponse->flushJson();
}
if (Request::getApiParam('action') === 'getContent') {
$oResponse->setData($oFtp->getContent(Request::getApiParam('item')));
$oResponse->flushJson();
}
if (Request::getApiParam('action') === 'rename') {
$item = Request::getApiParam('item');
$newItemPath = Request::getApiParam('newItemPath');
$result = $oFtp->move($item, $newItemPath);
if (!$result) {
throw new Exception("Unknown error renaming this item");
}
$oResponse->setData($result);
$oResponse->flushJson();
}
if (Request::getApiParam('action') === 'move') {
$items = Request::getApiParam('items');
$newPath = Request::getApiParam('newPath');
$errors = array();
foreach ($items as $item) {
$fileName = explode('/', $item);
$fileName = end($fileName);
$finalPath = $newPath . '/' . $fileName;
$result = $item ? $oFtp->move($item, $finalPath) : false;