WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDES  |  PHP CLASSES  |  CODE SEARCH  |  ARTICLES SEARCH  |  PHP FORUMS  |  PHP MANUAL  |  PHP FUNCTIONS LIST  |  WEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
WeberDev's Monthly code contest PHP Code Contest
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Index
PHP Web Logs (BLogs)
Web Development Resources
Web Development Content
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
Submit Site
Forex Trading Online forex trading platform

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : Recursively copying or moving files with PHP
Categories : PHP, Filesystem Click here to Update Your Picture
gaurav gaur
Date : Apr 25th 2008
Grade : 1 of 5 (graded 3 times)
Viewed : 569
File : No file for this code example.
Images : No Images for this code example.
Search : More code by gaurav gaur
Action : Grade This Code Example
Tools : My Examples List

  Submit your own code examples 
 

<?php
$dirsource
= "D:/websites/promo_one_root/server/promo_one/nfs/images";
$dirdest = "D:/websites/promo_one_root/server/promo_one/webroot/dest";
recursive_copy($dirsource, $dirdest);

function
recursive_copy($dirsource, $dirdest)
{
// recursive function to copy
  // all subdirectories and contents:
 
if(is_dir($dirsource))$dir_handle=opendir($dirsource);
 
$dirname = substr($dirsource,strrpos($dirsource,"/")+1);

 
mkdir($dirdest."/".$dirname, 0750);
   while(
$file=readdir($dir_handle))
  {
    if(
$file!="." && $file!="..")
    {
      if(!
is_dir($dirsource."/".$file)) copy ($dirsource."/".$file, $dirdest."/".$dirname."/".$file);
      else
      {
         
$dirdest1 = $dirdest."/".$dirname;
       
recursive_copy($dirsource."/".$file, $dirdest1);
      }
    }
  }
 
closedir($dir_handle);
  return
true;
}
echo
"dir copy";
die;


$dirsource = "D:/websites/promo_one_root/server/promo_one/test";
$dirdest = "D:/websites/promo_one_root/server/promo_one/test1";
recursive_move($dirsource, $dirdest);

function
recursive_move($dirsource, $dirdest)
{
// recursive function to copy
  // all subdirectories and contents:
 
if(is_dir($dirsource))$dir_handle=opendir($dirsource);
 
$dirname = substr($dirsource,strrpos($dirsource,"/")+1);

 
mkdir($dirdest."/".$dirname, 0750);
   while(
$file=readdir($dir_handle))
  {
    if(
$file!="." && $file!="..")
    {
      if(!
is_dir($dirsource."/".$file))
      {
     
copy ($dirsource."/".$file, $dirdest."/".$dirname."/".$file);
     
unlink($dirsource."/".$file);
      }
      else
      {
         
$dirdest1 = $dirdest."/".$dirname;
       
recursive_move($dirsource."/".$file, $dirdest1);
      }
    }
  }
 
closedir($dir_handle);
 
rmdir($dirsource);
}
?>



PHP4 DirectoryIterator Class
Categories : PHP, PHP Classes, Filesystem, Directories
Keep() - maintenance function for backup folders
Categories : PHP, Filesystem, Maintenance
Contents Page - a script to build contents pages.
Categories : Complete Programs, PHP, Utilities, Filesystem
Display list of files within current and subdirectories (recursively) showing each file as an anchored link and each directory as a category header.
Categories : Filesystem, Directories, Arrays, PHP
How to create an empty file? (touch)
Categories : Filesystem, PHP
Listing the 10 most recently updated files in a given dir by using last- modified variable and printing to html with link to the file
Categories : PHP, Directories, Filesystem
Unix Disk Information with graphs
Categories : PHP, Shell Scripting, Filesystem
Save and restore files into postgresql database (PHP SCRIPT) PHP CLASS
Categories : PHP, Databases, PostgreSQL, Filesystem
Differences between two files
Categories : PHP, Filesystem, Tip
how can I read the entire contents of a file into a string?
Categories : Filesystem, Strings, PHP
file class , uploade file , download file already uploaded on another website
Categories : PHP, PHP Classes, Filesystem, Web Services
How to let a user download a picture by clicking on it instead of needing to right click and Save-As.
Categories : HTTP, PHP, HTML and PHP, Filesystem
Introduction to Language Files
Categories : PHP, Filesystem, Beginner Guides
File Explorer, browse, upload, download and edit your web site files with only a browser and a HTTP connection.
Categories : Complete Programs, Content Management, Filesystem, PHP
Variable serialization and unserialization. Loading and saving variable structures to and from file.
Categories : Arrays, Filesystem, Variables, Strings, PHP