[原創]php+ajax實現類比Win檔案管理系統四_PHP教程

來源:互聯網
上載者:User
[原創]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 );
}
}

上一篇

http://www.bkjia.com/PHPjc/631853.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/631853.htmlTechArticle[原創]php+ajax實現類比Win檔案管理系統 //本教程由本站原創,轉載請註明來處 作者:www.drise.cn 郵箱:drise@163.com QQ:271728967// 上面我們講到了, De...

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.