You upload a PNG to a web server. It looked fine on your computer. On the site it is broken, or it refuses to load at all. You have just met the png corrupted after ftp upload problem. The culprit is almost always FTP ASCII mode, which rewrites line endings and quietly destroys binary data. Here is how that happens, how the PNG format itself catches the damage, and how to fix it and stop it happening again.
How ASCII Mode Corrupts PNG Files
Two Modes, One Destroys Images
FTP gives you two ways to move a file: ASCII (text mode) and binary (image mode). ASCII mode exists for plain text. When you send a file this way, the FTP client converts line endings to match the destination system. Windows uses the bytes 0D 0A. Unix and Linux use just 0A. Upload from Windows to Unix, and ASCII mode strips the 0D. Go the other way, and it inserts one.
PNG files are binary. They contain every possible byte sequence, including 0D and 0A scattered through the pixel data and the file structure. ASCII mode cannot tell the difference. It converts those bytes wherever it finds them. The file is now unreadable. The result: images broken after ftp upload.
The PNG Signature Detects the Problem
A Built-in Tamper Seal
The first eight bytes of every PNG file form a signature. It includes the bytes 0D 0A and 0A in specific positions, placed there deliberately by the format's designers. Transfer the file in ASCII mode and the line-ending conversion changes those signature bytes. Any PNG viewer or editor checks the signature first. If the bytes are wrong, the program knows the file is corrupt and throws an error immediately.
You see a message like "invalid PNG signature," or the image simply fails to open. The signature check is a safeguard. It tells you, right away, that something went wrong during the move.
Preventing Corruption Use Binary Mode
Re-upload the Right Way
The fix is to send the original, undamaged PNG again, this time in binary mode. ASCII mode must never touch images, executables, archives, or any other binary file.
Set binary mode in common FTP clients:
- In FileZilla, go to Transfer > Transfer type > Binary. The other choices are Auto and ASCII. Auto tries to guess the file type, but it guesses wrong often enough with PNGs. Set it to Binary. No conversion happens.
- In the command-line ftp client, type the command binary before you start the move. That switches the session to binary mode.
If you use SFTP, the problem does not exist. SFTP moves every file as binary and never converts line endings. Use SFTP instead of FTP and you sidestep the whole mess.
Repairing a Corrupted PNG After ASCII Transfer
When the Original Is Gone
You already uploaded the PNG in ASCII mode and the original file is lost. The damaged copy may be partly recoverable. The corruption is limited to byte changes wherever 0D 0A or 0A sequences appeared. How many of those sequences existed determines whether the image is partly viewable or completely unreadable.
Recovery Steps
- Download the corrupted file from the server to your local machine.
- Make a backup copy of the corrupted file.
- Try opening the file in a PNG viewer. If it opens partially, you may see horizontal streaks or missing sections. Some image editors can load these files and let you re-save them.
- If the file does not open, specialized recovery tools may reconstruct the data by reversing the byte changes. This is not guaranteed.
The simplest and most reliable solution is to re-upload the original file in binary mode. No original? You need to get it from another source.
Checking Your FTP Client Settings
Stop It Before It Starts
To avoid png corrupted after upload next time, check your FTP client settings before every session. Many clients remember the last mode used. If you moved a text file in ASCII, the next move may also use ASCII unless you change it.
For FileZilla users: after you set Transfer > Transfer type to Binary, the setting sticks until you change it again. You can also set default modes per server in the site manager.
For command-line ftp users: put the binary command in a script or batch file so it runs before any put or mput commands.
Why Website Images Fail After FTP Upload
The Browser Shows Nothing
When website images not loading after ftp is the symptom, the browser displays a broken image icon or a blank space. The cause is the same ASCII mode corruption. The web server hands the damaged file to the browser. The browser cannot decode it as a PNG. You get an error like "image cannot be displayed," or you get nothing at all.
Uploaded many images? Check which ones are corrupt by comparing the file size on the server to the original. ASCII mode changes the file size because of the byte conversions. A size mismatch is a strong corruption indicator.
The Difference Between FTP ASCII and Binary Mode
One Rule Covers Everything
The ftp ascii vs binary mode distinction comes down to line endings. ASCII mode converts 0D 0A and 0A sequences. Binary mode moves every byte exactly as it is. For any file that is not plain text, use binary mode. That means PNG, JPEG, GIF, ZIP, PDF, and executable files.
Unsure whether a file is text or binary? Treat it as binary. Text files are only those with human-readable characters and line endings for paragraph breaks. Source code files (.html, .css, .js) are often text, but many developers send them in binary mode anyway to avoid surprises. The safest rule: unless you are certain the file is plain text, use binary mode.