[Original] php + ajax to simulate Win file management system 4_php tutorial

Source: Internet
Author: User
[Original] php + ajax to simulate Win file management system 4. [Original] php + ajax to achieve the simulation of Win file management system this tutorial by the site original, reproduced please indicate the author: www.drise.cn mailbox: drise@163.comQQ: 271728967 above we talked about, de [original] php + ajax to simulate Win file management system

// This tutorial is original on this site. For more information, see here.

Author: www.drise.cn

Email: drise@163.com

QQ: 271728967 //

As we mentioned above,Deletefile () function. next we will talk about the Createfolder () function.

Function Createfolder ($ path, $ nname ){
If (is_dir ($ path) & is_writable ($ path) {// whether the directory is writable
If (preg_match ("/^ \ w {1,255} $/I", $ nname) {// you can determine the validity of a file.
Echo mkdir ($ path. "/". $ nname, 0777 )? 'Create Folder success ': 'Create Folder Fail'; // 0777 sets whether the file can be read or written.
} Else {
Echo "Folder Error ";
}
} Else {
Echo "Can't Create Error file not is_writable or not dir ";
}}

This function is used to create folders,

Past ($ path, $ nname, $ cpath) function

Function Past ($ currentpath, $ currentfilename, $ filepote) {// 1: location where the file is to be pasted 2: current file {folder} name 3: physical address of the file {folder}
$ 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'; // The full_copy function is followed by recursive folder reading.
} 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': 'error ';
} If ($ str = "|" & $ t ='t '){
Deldir ($ filepote );
}
}

Function full_copy ($ source, $ target) // This function is from the official site of php and is used to recursively copy files from folders.
{

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 );
}
}

Previous

Author // This tutorial by the site original, reproduced please indicate the author: www.drise.cn mailbox: drise@163.com QQ: 271728967 // above we talked about, De...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.