Introduction: This is a detailed page for PHP to check whether the uploaded file already exists or has the same name. It introduces PHP, PHP, file, path, file PHP checks whether the uploaded file already exists or has the same name related knowledge, skills, experience, and some PHP source code.
Class = 'pingjiaf' frameborder = '0' src = 'HTTP: // biancheng.dnbc?info/pingjia.php? Id = 344669 'rolling = 'no'>
// Check whether a file with the same name already exists in the directory of the uploaded file
Function searchfile ($ path, $ file) {$ file_array = array (); // stores an array of file names $ folder_array = array (); // store the directory name array $ all_array = array (); // store the array of all paths if (is_dir ($ PATH )) {// check whether the file directory exists $ H = @ opendir ($ PATH); While (false! ==( $ _ File = readdir ($ H) {// retrieve the 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); // retrieves a file} elseif (is_file ($ path. "/". $ _ file) & $ _ file! = "." & $ _ File! = "..." & $ _ File! = "Thumbs. DB ") {echo $ _ file; echo '<br>'; // $ _ file = auto_charset ($ _ file, 'utf-8', 'gbk '); if (eregi ('/'. $ file ,'/'. $ _ file) {array_push ($ file_array, $ path. "/". $ _ file); Return 'yes'; // file existence }}// $ 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'; // file existence} else {return 'no '; // file does not exist} else {return 'no'; // file does not exist }}
Love J2EE follow Java Michael Jackson video station JSON online tools
Http://biancheng.dnbcw.info/php/344669.html pageno: 4.