PHP in the directory to check the upload file, there is already an upload file with the same name
Check to see if an uploaded file with the same name already exists in the directory where the file was uploaded
?
function Searchfile ($path, $file) {$file _array=array ();//Store file name array $folder_array=array ();//store directory an array group $all_array=array () ; Array if all paths are stored (Is_dir ($path)) {//Check file directory for presence $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 the file}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 '; File exists}}}//$this->all_array["folder"]= $this->folder_array;//$this->all_array["file"]= $this->file_ Array;closedir ($H); return ' no '; There is no}elseif (Is_file ($path)) {if (Eregi ($file, $path)) {//$this->all_array["file"]= $path; return ' yes ';//File exists} else {return ' no ';//file does not exist}}else{return ' no ';//file does not exist}}
?
?