Create a folder-PHP source code

Source: Internet
Author: User
Ec (2); Create a folder & nbsp; copy the code functionCreatefolder ($ path, $ nname) {& nbsp; if (is_dir ($ path) & amp; is_writable ($ path) {& nbsp; if (preg_match (& quot; ^ w {1,255} $ I & quot;, $ nname) script ec (2 ); script

Create a folder

The Code is as follows:

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 ';
} Else {
Echo "Folder Error ";
}

} Else {
Echo "Can't Create Error file not is_writable or not dir ";}

}

Paste a file

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) = "| "){


Www.111cn.net


$ Currentfilename = str_replace ("|", "", $ currentfilename );



$ Filepote = str_replace ("|", "", $ filepote );


} Www.111cn.net



If (is_dir ($ currentpath) & is_writable ($ currentpath) & is_dir ($ filepote) & is_writable ($ filepote )){

Www.111cn.net


// @ Mkdir ($ currentpath. "/". $ currentfilename );
$ T = full_copy ($ filepote, $ currentpath. "/". $ currentfilename )? 'T': 'F'; // $ filepote, need copy folder $ current sava folder

Www.111cn.net


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

Www.111cn.net


}


If ($ str = "|" & $ t = 'T '){



Deldir ($ filepote );

Www.111cn.net


}


}

Original article: www.111cn.net

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.