×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: PHP
Posted by: Jackomo Light
Added: Feb 26, 2013 12:50 AM
Views: 30
Tags: php files move
Move files from one dir to another
  1.     // Get array of all source files
  2.     $files = scandir("source");
  3.     // Identify directories
  4.     $source = "source/";
  5.     $destination = "destination/";
  6.     // Cycle through all source files
  7.     foreach ($files as $file) {
  8.       if (in_array($file, array(".",".."))) continue;
  9.       // If we copied this successfully, mark it for deletion
  10.       if (copy($source.$file, $destination.$file)) {
  11.         $delete[] = $source.$file;
  12.       }
  13.     }
  14.     // Delete all successfully-copied files
  15.     foreach ($delete as $file) {
  16.       unlink($file);
  17.     }