[原创]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...