imanewbe Posted May 8, 2014 Share Posted May 8, 2014 I am using ftp_get to download files but sometimes when it downloads an image it downloads it but the image is damaged. So it seems like it is only downloading part of the image then closing the connection to that file. The ftp_get still returns true. here is what I am doing public function download_single_file($file, $dest_file){ return ftp_get($this->ftp_conn, $dest_file, $file, FTP_ASCII); } Any ideas on why this may be happening? Thanks in advance for any assistance. Quote Link to comment https://forums.phpfreaks.com/topic/288330-php-ftp_get-not-downloading-entire-files/ Share on other sites More sharing options...
Solution jazzman1 Posted May 8, 2014 Solution Share Posted May 8, 2014 Have you tried using ftp_binary instead ftp_ascii when you're dealing with images? Quote Link to comment https://forums.phpfreaks.com/topic/288330-php-ftp_get-not-downloading-entire-files/#findComment-1478700 Share on other sites More sharing options...
imanewbe Posted May 22, 2014 Author Share Posted May 22, 2014 I tried both FTP_ASCII and FTP_BINARY and both have the same effect. This is what the file should look like: and this is what it looks like when I download it using ftp_get with either FTP_ASCII or FTP_BINARY Quote Link to comment https://forums.phpfreaks.com/topic/288330-php-ftp_get-not-downloading-entire-files/#findComment-1480413 Share on other sites More sharing options...
imanewbe Posted May 22, 2014 Author Share Posted May 22, 2014 Disregard my previous comment. That worked perfectly. Thanks for that. Should I change between FTP_ASCII and FTP_BINARY depending if I am downloading a text file or image? Quote Link to comment https://forums.phpfreaks.com/topic/288330-php-ftp_get-not-downloading-entire-files/#findComment-1480415 Share on other sites More sharing options...
jazzman1 Posted May 22, 2014 Share Posted May 22, 2014 I think, you do not need to worry about manually configuring the proper mode when transferring files using this php ftp library. Wouldn't be automatically determining the proper transfer mode based upon the contents of the file or the file's extension? Quote Link to comment https://forums.phpfreaks.com/topic/288330-php-ftp_get-not-downloading-entire-files/#findComment-1480423 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.