本文整理汇总了PHP中FileUtil::moveDir方法的典型用法代码示例。如果您正苦于以下问题:PHP FileUtil::moveDir方法的具体用法?PHP FileUtil::moveDir怎么用?PHP FileUtil::moveDir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileUtil
的用法示例。
在下文中一共展示了FileUtil::moveDir方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: moveDir
/**
* 移动文件夹
*
* @param string $oldDir
* @param string $aimDir
* @param boolean $overWrite 该参数控制是否覆盖原文件
* @return boolean
*/
static function moveDir($oldDir, $aimDir, $overWrite = false)
{
$aimDir = str_replace('', '/', $aimDir);
$aimDir = substr($aimDir, -1) == '/' ? $aimDir : $aimDir . '/';
$oldDir = str_replace('', '/', $oldDir);
$oldDir = substr($oldDir, -1) == '/' ? $oldDir : $oldDir . '/';
if (!is_dir($oldDir)) {
return false;
}
if (!file_exists($aimDir)) {
FileUtil::createDir($aimDir);
}
@($dirHandle = opendir($oldDir));
if (!$dirHandle) {
return false;
}
while (false !== ($file = readdir($dirHandle))) {
if ($file == '.' || $file == '..') {
continue;
}
if (!is_dir($oldDir . $file)) {
FileUtil::moveFile($oldDir . $file, $aimDir . $file, $overWrite);
} else {
FileUtil::moveDir($oldDir . $file, $aimDir . $file, $overWrite);
}
}
closedir($dirHandle);
return rmdir($oldDir);
}
示例2: move
/**
* @Title: move
* @Description: todo(移动文件)
* @author liminggang
* @date 2013-8-16 下午3:29:40
* @throws
*/
public function move()
{
//表示执行操作还是执行页面跳转
$step = $_POST['step'];
//当前选中要移动的文件ID
$id = $_REQUEST['id'];
$this->assign('id', $id);
//实例化对象
$name = $this->getActionName();
if ($step) {
$MisFileManagerModel = D($name);
//需要移动到的文件夹ID
$parentid = $_POST['parentid'];
if ($id == $parentid) {
$this->success("文件移动成功");
exit;
}
//第一步、修改数据库
$movetolist = $MisFileManagerModel->where('id = ' . $parentid . ' and status = 1')->find();
//获取移动的文件数据
$map = array();
$map['id'] = array(' in ', explode(',', $id));
$map['status'] = 1;
$movelist = $MisFileManagerModel->where($map)->select();
$FileUtil = new FileUtil();
foreach ($movelist as $k => $onemove) {
//进行递归修改数据库文件结构
$this->reCursion($onemove['id'], $parentid);
//不是文件夹,则直接判断重名问题
if ($onemove['type'] == 0) {
//获得移动文件名称
$movefilename = $onemove['uploadname'];
} else {
//移动类型为文件夹,则判断是否有重名文件夹。
$movefilename = $onemove['uploadname'];
}
//组合一个新的移动路径
$nowfilepath = $movetolist['filepath'] . "/" . $movefilename;
if ($movetolist['parentid'] == 0) {
$nowfilepath = $movetolist['filepath'] . "/" . $_SESSION[C('USER_AUTH_KEY')] . "/" . $movefilename;
}
$nowfilepath = UPLOAD_PATH . "MisFileManager/" . $nowfilepath;
$oldfilepath = $onemove['filepath'];
$oldfilepath = UPLOAD_PATH . "MisFileManager/" . $oldfilepath;
//实例化文件操作对象
if ($onemove['type'] == 1) {
//移动的是文件夹
$boolean = $FileUtil->moveDir($oldfilepath, $nowfilepath);
if (!$boolean) {
$this->error("文件夹[" . $onemove['name'] . "]移动失败");
}
} else {
//移动的是文件
$boolean = $FileUtil->moveFile($oldfilepath, $nowfilepath, true);
if (!$boolean) {
$this->error("文件[" . $onemove['name'] . "]移动失败");
}
}
}
$this->success("文件移动成功");
} else {
$model = D("MisFileManager");
$managerid = array(1);
$sytlist = array();
$arr[] = array("id" => 0, "pId" => -1, "realid" => 0, "category" => 0, "name" => "文档树形结构", "open" => true, "title" => "文档树形结构");
//系统默认的文件夹
$map = array();
$map['type'] = 1;
//文件夹
$map['status'] = 1;
//状态为正常
$map['issystem'] = 1;
//为系统文件
$map['category'] = array("neq", 5);
$sytlist = $model->where($map)->select();
$sytlist = array_merge($arr, $sytlist);
$map = array();
//查询我的文件夹
$map['type'] = 1;
$map['status'] = 1;
$map['category'] = 1;
$map['issystem'] = 0;
$map['createid'] = $_SESSION[C('USER_AUTH_KEY')];
$list = $model->where($map)->select();
if ($list) {
$sytlist = array_merge($sytlist, $list);
foreach ($list as $k => $v) {
array_push($managerid, $v["id"]);
}
}
//查询单位 公文
if ($_SESSION['a']) {
//如果是管理员不过滤
//.........这里部分代码省略.........
示例3: SQLTool
require_once "../smarty_include.php";
require_once "../tools/SQLTool.class.php";
require_once "../tools/FileUtils.php";
$sqltool = new SQLTool();
$fileutil = new FileUtil();
//发布通知
if (isset($_POST['add_news'])) {
$news_title = $_POST['news_title'];
$news_content = $_POST['news_content'];
$attach_id = $_POST['attach_id'];
$news_author = $_SESSION['user_name'];
$sql = "insert into t_news(news_title,news_content,attach_id,news_time,news_author) values('{$news_title}','{$news_content}','{$attach_id}',NOW(),'{$news_author}')";
$res = $sqltool->dbUpdate($sql);
$res1 = 1;
if (file_exists(PROJECT_DIR . "/uploadfile/temp/" . $attach_id)) {
$res1 = $fileutil->moveDir(PROJECT_DIR . "/uploadfile/temp/" . $attach_id, PROJECT_DIR . "/uploadfile/files/news/" . $attach_id);
}
if ($res and $res1) {
echo "<script>alert('通知发布成功!')</script>";
} else {
echo "<script>alert('通知发布失败!')</script>";
}
echo "<script>window.location.href='/itildemo/home/controller/admin/news_create.php'</script>";
}
//删除通知
if (isset($_GET['news_delete'])) {
$news_id = $_GET['news_delete'];
$sql = "delete from t_news where news_id='{$news_id}'";
if ($sqltool->dbUpdate($sql)) {
echo "<script>alert('通知删除成功!')</script>";
} else {
示例4: CONCAT
$req_source = $_POST['req_source'];
$req_author = $_POST['req_author'];
} else {
$req_author = $_SESSION['user_name'];
$req_source = "1";
}
$req_title = $_POST['req_title'];
$req_sort = $_POST['req_sort'];
$req_attach_id = $_POST['attach_id'];
$req_content = $_POST['req_content'];
$req_keyword = $_POST['req_keyword'];
$sql = "INSERT INTO t_req (req_num,req_title,req_sort,req_author,req_attach_id,req_content,req_time,req_keyword,req_source) VALUES\r\n (\r\n (SELECT CONCAT('REQ',DATE_FORMAT(NOW(),'%y%m%d'),id) FROM\r\n (\r\n SELECT\r\n CASE\r\n WHEN req_num IS NULL THEN '00001'\r\n ELSE LPAD(RIGHT(MAX(req_num),5)+1,5,'0')\r\n END id FROM t_req\r\n WHERE req_num LIKE CONCAT('REQ',DATE_FORMAT(NOW(),'%y%m%d'),'%')\r\n ) req_num),'{$req_title}','{$req_sort}','{$req_author}','{$req_attach_id}','{$req_content}',Now(),'{$req_keyword}','{$req_source}'\r\n )";
//上传的文件移动
$res = 1;
if (file_exists(PROJECT_DIR . "/uploadfile/temp/" . $req_attach_id)) {
$res = $fileutil->moveDir(PROJECT_DIR . "/uploadfile/temp/" . $req_attach_id, PROJECT_DIR . "/uploadfile/files/req/" . $req_attach_id);
}
if ($sqltool->dbUpdate($sql) and $res) {
echo "<script>alert('请求添加成功!')</script>";
} else {
echo "<script>alert('请求添加失败!');</script>";
}
if ($flag == "admin") {
echo "<script>window.location.href='/itildemo/home/controller/admin/request_create.php'</script>";
} else {
echo "<script>window.location.href='/itildemo/home/controller/user/request_create.php'</script>";
}
}
//指派请求
if (isset($_POST['assign_btn'])) {
$req_num = $_POST['req_num'];
示例5: CONCAT
if (isset($_POST['add_kno'])) {
$kno_title = $_POST['kno_title'];
$kno_author = $_SESSION['user_name'];
$kno_sort = $_POST['kno_sort'];
$kno_keyword = $_POST['kno_keyword'];
$kno_req_num = $_POST['req_num'];
$kno_attach_id = $_POST['attach_id'];
$kno_content = $_POST['kno_content'];
if ($kno_req_num == "") {
$kno_req_num = NULL;
}
$sql = "INSERT INTO t_kno (kno_num,kno_title,kno_sort,kno_author,kno_attach_id,kno_content,kno_sub_time,kno_keyword,kno_req_num) VALUES\r\n (\r\n (SELECT CONCAT('KNO',DATE_FORMAT(NOW(),'%Y%m%d'),id) FROM\r\n (\r\n SELECT\r\n CASE\r\n WHEN kno_num IS NULL THEN '00001'\r\n ELSE LPAD(RIGHT(MAX(kno_num),5)+1,5,'0')\r\n END id FROM t_kno\r\n WHERE kno_num LIKE CONCAT('KNO',DATE_FORMAT(NOW(),'%Y%m%d'),'%')\r\n ) kno_num),'{$kno_title}','{$kno_sort}','{$kno_author}','{$kno_attach_id}','{$kno_content}',Now(),'{$kno_keyword}','{$kno_req_num}'\r\n )";
//将上传的文件从temp文件夹下移到files
$res = 1;
if (file_exists(PROJECT_DIR . "/uploadfile/temp/" . $kno_attach_id)) {
$res = $fileutil->moveDir(PROJECT_DIR . "/uploadfile/temp/" . $kno_attach_id, PROJECT_DIR . "/uploadfile/files/know/" . $kno_attach_id);
}
if ($sqltool->dbUpdate($sql) and $res) {
echo "<script>alert('知识采集成功!')</script>";
} else {
echo "<script>alert('知识采集失败!')</script>";
}
echo "<script>window.location.href='/itildemo/home/controller/share/know_create.php'</script>";
}
//发布
if (isset($_GET['flag']) and $_GET['flag'] == 'pass') {
$kno_num = $_GET['kno_num'];
$res = $sqltool->dbUpdate("update t_kno set kno_state=3 where kno_num = '{$kno_num}'");
if ($res) {
echo "<script>alert('发布成功!')</script>";
} else {
示例6: elseif
} elseif ($_GET['tj'] == 'no') {
$id = intval($_GET['id']);
DB::query("UPDATE " . DB::table('forum_alliance_ar') . " SET top='0' WHERE id='{$id}'");
cpmsg($php_lang['ltuijianno'], $appurl);
}
} elseif ($p == 'tui') {
$id = intval($_GET['id']);
DB::query("UPDATE " . DB::table('forum_alliance_ar') . " SET tuis='1' WHERE id='{$id}'");
if ($fidstart == 1) {
include_once 'source/plugin/dz55625_plate/plate_get.inc.php';
}
cpmsg($php_lang['tuisongok'], $appurl);
} elseif ($p == 'diy') {
include_once 'source/plugin/dz55625_haodian/haodian_Size.class.php';
if ($_GET['d'] == 'yes') {
FileUtil::moveDir('source/plugin/dz55625_haodian/function/', 'source/class/block/haodian');
cpmsg($php_lang['diy_start'], $appurl);
}
} elseif ($p == 'del') {
$id = intval($_GET['id']);
$active = DB::fetch_first("SELECT * FROM " . DB::table('forum_alliance_ar') . " WHERE id ='{$id}' LIMIT 0 , 1");
$actives = DB::fetch_first("SELECT * FROM " . DB::table('forum_alliance_img') . " WHERE aid ='{$id}' LIMIT 0 , 1");
DB::query("DELETE a,b,c,d,e FROM " . DB::table('forum_alliance_ar') . " AS a LEFT JOIN " . DB::table('forum_alliance_pl') . " AS b ON a.id = b.sid LEFT JOIN " . DB::table('forum_alliance_img') . " AS c ON a.id = c.aid LEFT JOIN " . DB::table('forum_alliance_wp') . " AS d ON a.id = d.sid LEFT JOIN " . DB::table('forum_alliance_yh') . " AS e ON a.id = e.aid WHERE a.id = '{$id}' ");
if ($active["pic"] != false) {
unlink($active["pic"] . $filetype);
}
if ($actives["img"] != false) {
unlink($actives["img"] . $filetype);
}
cpmsg($php_lang['lshanchuok'], $appurl);
} else {