1024programmer PHP In php, check whether a downloaded file with the same name already exists in the directory of the downloaded file.

In php, check whether a downloaded file with the same name already exists in the directory of the downloaded file.

Check in php whether an uploaded file with the same name already exists in the directory of the uploaded file

Check whether an uploaded file with the same name already exists in the directory where you uploaded the file

?

function searchFile($path,$file){
 $file_array=array(); //Storage array of file names
 $folder_array=array(); //Storage array of directory names
 $all_array=array(); //array to store all paths

 if(is_dir($path)){ //Check whether the file directory exists
 $H = @ opendir($path);
 while(false !== ($_file=readdir($H))){
 //Retrieve directory
 if(is_dir($path."/".$_file) && $_file != "." && $_file!=".." && $_file!=="Thumbs.db"){
 if(eregi('/'.$file,'/'.$_file)){
 array_push($folder_array,$path."/".$_file);
 }
 searchFile($path."/".$_file,$file);
 //Retrieve files
 }elseif(is_file($path."/".$_file) && $_file!="." && $_file!=".." && $_file!=="Thumbs.db"){
 echo $_file;
 echo '
'; //$_file = auto_charset($_file,'utf-8','gbk'); if(eregi('/'.$file,'/'.$_file)){ array_push($file_array,$path."/".$_file); return 'yes'; //The file exists } } } //$this->all_array["folder"]=$this->folder_array; //$this->all_array["file"]=$this->file_array; closedir($H); return 'no'; //does not exist }elseif(is_file($path)){ if(eregi($file,$path)){ //$this->all_array["file"]=$path; return 'yes'; //The file exists } else { return 'no'; //The file does not exist } }else{ return 'no'; //The file does not exist } }

?

?

This article is from the internet and does not represent1024programmerPosition, please indicate the source when reprinting:https://www.1024programmer.com/in-php-check-whether-a-downloaded-file-with-the-same-name-already-exists-in-the-directory-of-the-downloaded-file/

author: admin

Previous article
Next article

Leave a Reply

Your email address will not be published. Required fields are marked *

Contact Us

Contact us

181-3619-1160

Online consultation: QQ交谈

E-mail: [email protected]

Working hours: Monday to Friday, 9:00-17:30, holidays off

Follow wechat
Scan wechat and follow us

Scan wechat and follow us

Follow Weibo
Back to top
首页
微信
电话
搜索