In this article am going to talk about how to move or copy files between the servers. When you decided to migrate from your current hosting provider or if you got a new server or some time from your development environment to you might need to move/copy you data to new server.
Usually it’s a painful process of downloading all these data and uploading to new host again. By using PHP ftp functions you can easy copy/move your data from one server to another.
//Include the FTP class - I have used Codeigniter FTP Class require_once('Ftp.php'); $ftp = new CI_FTP(); //Host of the old server where you have backup data $config['hostname'] = 'IP Address goes here'; //FTP username $config['username'] = 'Username'; //FTP Password $config['password'] = 'password'; //Debug - If required $config['debug'] = TRUE; //COnnect FTP $ftp->connect($config); //You can upload the file using below line of code // $ftp->upload(LOCAL PATCH, REMOTE PATH); $ftp->download('filename.zip', '/public_html/filename.zip'); //Close FTP $ftp->close();