搜尋
首頁php教程php手册[原创]php+ajax实现模拟Win文件管理系统四

[原创]php+ajax实现模拟Win文件管理系统四

Jun 13, 2016 am 09:59 AM
php+ajaxwin原創實現文件模擬管理系統

[原创]php+ajax实现模拟Win文件管理系统

//本教程由本站原创,转载请注明来处

作者:www.drise.cn

邮箱:drise@163.com

QQ:271728967//

上面我们讲到了,Deletefile()函数,下面我们接着讲Createfolder()函数

function Createfolder($path,$nname){
 if(is_dir($path) && is_writable($path)){//是否为目录且可写
  if(preg_match("/^\w{1,255}$/i",$nname)){//判断文件的合法性
   echo mkdir($path."/".$nname,0777)?'Create Folder success':'Create Folder Fail';//0777是设置文件可读写
  }else{
   echo "Folder Error";
  }
 }else{
  echo "Can't Create Error file not is_writable or not dir";
 }}

这个函数的功能是实现文件夹的建,

Past($path,$nname,$cpath)函数

function Past($currentpath,$currentfilename,$filepote){ //1:文件要被粘贴到的位置2:当前文件{夹}名3:文件{夹}所在的物理地址  
  $str = substr($currentfilename,-1,1);
  if(substr($currentfilename,-1,1)=="|"){
   $currentfilename = str_replace("|","",$currentfilename);
   $filepote   = str_replace("|","",$filepote);
  }
  if(is_dir($currentpath) && is_writable($currentpath) && is_dir($filepote) && is_writable($filepote)){
   //@mkdir($currentpath."/".$currentfilename);
   $t=full_copy($filepote,$currentpath."/".$currentfilename)?'t':'f';//full_copy函数下面接,是进行递归读取文件夹
  }else if(is_file($filepote) && file_exists($filepote)){
   if(file_exists($currentpath.$currentfilename)){ echo ('file exists! plase rename it!');exit;}
    echo copy($filepote,$currentpath.$currentfilename)?'success':'errror';  
}  if( $str =="|" && $t='t' ){ 
   deldir($filepote);
  }
}

function full_copy( $source, $target )//这个函数来自php官方站,功能是进行文件夹递归拷贝文件
    {

        if ( is_dir( $source ) )
        {
            @mkdir( $target ); 
            $d = dir( $source );
            while ( FALSE !== ( $entry = $d->read() ) )
            {
            if ( $entry == '.' || $entry == '..' )
                {
                        continue;
                }
                $Entry = $source . '/' . $entry;
                if ( is_dir( $Entry ) )
                {
                   full_copy( $Entry, $target . '/' . $entry );
                    continue;
                }
                copy( $Entry, $target . '/' . $entry );
            }
            $d->close();
        }else {
            copy( $source, $target );
        }
    }

上一篇

陳述
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn

熱AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool

Undress AI Tool

免費脫衣圖片

Clothoff.io

Clothoff.io

AI脫衣器

AI Hentai Generator

AI Hentai Generator

免費產生 AI 無盡。

熱門文章

R.E.P.O.能量晶體解釋及其做什麼(黃色晶體)
1 個月前By尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.最佳圖形設置
1 個月前By尊渡假赌尊渡假赌尊渡假赌
威爾R.E.P.O.有交叉遊戲嗎?
1 個月前By尊渡假赌尊渡假赌尊渡假赌

熱工具

PhpStorm Mac 版本

PhpStorm Mac 版本

最新(2018.2.1 )專業的PHP整合開發工具

SublimeText3 Linux新版

SublimeText3 Linux新版

SublimeText3 Linux最新版

VSCode Windows 64位元 下載

VSCode Windows 64位元 下載

微軟推出的免費、功能強大的一款IDE編輯器

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

強大的PHP整合開發環境

記事本++7.3.1

記事本++7.3.1

好用且免費的程式碼編輯器