Monday, January 30, 2017

Copy all file from a folder to another PHP





// Get array of all source files into source_folder
$files = scandir("source_folder");

// Identify directories inside source_folder
$source = "source_folder/";
$destination = "destination_folder/";

// Cycle through all source files
foreach ($files as $file) {
  if (in_array($file, array(".",".."))) continue;
      copy($source.$file, $destination.$file);
  }
}


If we want to transfer all files from a folder to another follow this URL: http://programming-scripts.blogspot.com/2017/01/move-all-file-from-folder-to-another-php.html


No comments:

Post a Comment