Sunday, October 16, 2016

Transfer files server to server within few second using simple PHP functions

If you frustrated to transfer the big size of files from your old server to new server. You can use this simple PHP script to move files from one server to your destination server within few second.


Simply create a .php file in the destination server and load the file once in your browser.


For example: Create a file in your destination directory "file.php" and in "files.php" add this PHP code. finally run your file via browser like URL "http://destination-url/file.php"


 <?php  
   /**  
   * Transfer Files Server to Server using PHP fopen  
   * @link https://wpsohel.blogspot.com  
   */  
   set_time_limit(0); //Unlimited max execution time  
   $file_name = 'backup.zip'; //New file name  
   $url = 'http://www.wordpress.org/latest.zip'; //Source file URL. Need to change with your URL  
   $copy = file_put_contents($file_name, fopen($url, "r")); //Transfer the file from source url to destination server  
   //notice for success/failure   
   if ( !$copy ){  
    echo 'Ops! Failed, You may check source file URL or <a target="_blank" href="http://wpsohel.blogspot.com/p/contact.html">Need help?<a>';  
   }else {  
    echo 'WOW! Success';  
   }  
 ?>  

After you import/export the file, always delete the PHP file you use to do this task to prevent other people using it.


I hope it's useful for you a simple way to move files from server to server. 


This way you can transfer Website  from old server to new server within few moment.