move all files in a folder to another?

前端 未结 11 1993
一个人的身影
一个人的身影 2020-12-01 04:01

when moving one file from one location to another i use

rename(\'path/filename\', \'newpath/filename\');

how do you move all files in a fol

11条回答
  •  天涯浪人
    2020-12-01 04:30

    As a side note; when you copy files to another folder, their last changed time becomes current timestamp. So you should touch() the new files.

    ... (some codes for directory looping) ...
    if (copy($source.$file, $destination.$file)) {
       $delete[] = $source.$file;
    
       $filetimestamp = filemtime($source.$file); 
       touch($destination.$file,$filetimestamp);
    }
    ... (some codes) ...
    

提交回复
热议问题