Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $ftpHost = 'ftp.site.in';
- $ftpUsername = 'username';
- $ftpPassword = '******';
- // open an FTP connection
- $connId = ftp_connect($ftpHost) or die("Couldn't connect to $ftpHost");
- // try to login
- if(@ftp_login($connId, $ftpUsername, $ftpPassword)){
- echo "Connected as $ftpUsername@$ftpHost";
- }else{
- echo "Couldn't connect as $ftpUsername";
- }
- $contents = ftp_nlist($connId, ".");
- var_dump($contents);
- // local & server file path
- $localFilePath = 'csv';
- $remoteFilePath = 'public_html/csvfiles/';
- // try to download a file from server
- if(ftp_get($connId, $localFilePath, $remoteFilePath, FTP_BINARY)){
- echo "File transfer successful - $localFilePath";
- }else{
- echo "There was an error while downloading $localFilePath";
- }
Add Comment
Please, Sign In to add comment