Search code examples
phpcopyrenamemove

Quickest way to move whole folder's files to other folder using PHP


In php , rename function allow moving files to other folder however, what is the most efficient way to move all files from one folder to another folder?

@rename($fail_path, $incoming_path); is not working

If I have to implement this, I need to

foreach (scandir($fail_path) as $file){
  rename($fail_path.$file, $incoming_path.$file);
}

Is it consume resource / are there more straight way? thanks


Solution

  • Try shell_exec() function? Using shell_exec to call mv command.