i used ftp-get function to download images from server. But by accident i used FTP_ASCII mode, so i have a problem. Images couldn’t be read, there is some error.
I have no option to download images again.
Anyone knows how to convert these files into binary form, or how to repair these files?
There is no guaranteed way to repair the files because of the nature of the way ASCII mode works compared to Binary mode.
FTP ASCII mode is designed to convert line endings to the appropriate type between the source and destination operating systems. The most common conversion that is done here is
\n(0x0a) becomes\r\n(0x0d0a) and vice versa, when transferring between *nix and Windows.Lets say that we are transferring some images from a Linux server to a Windows machine, and we accidentally use ASCII mode. The FTP client is looking out for any
\nsequences in the incoming data and converting them to\r\nin the data it saves to disk. This means that anywhere in the binary data there is a0x0ait becomes0x0d0ain the new data. But it won’t convert an existing\r\nto\r\r\n– this will be left intact. No problem, you might think, I’ll just convert all the0x0d0aback to0x0aand the file will be repaired. But wait… if the existing\r\nsequences weren’t converted, then they will be converted the wrong way in this new conversion pass.The long of the short of it is you data is irrevocably corrupted. The only 100% guaranteed way to get the correct data back is to copy them off the server again, in binary mode.