Fix Zip Corrupting After Uploading It Via FTP

February 21st, 2013 - Posted by Steve Marks to Miscellaneous, PHP, Software, Web Development.

I came across a problem recently when uploading a Zip file via FTP. The Zip file would open fine before sending, however trying to open and extract it on the remote server resulted in an error. Inparticular, when opening the file with WinZip the error was as follows:

Error: central directory not found

The Solution

The problem turned out to be the mode in which the file was being transferred. There are two modes of upload when it comes to putting files with FTP: ASCII or Binary. Initially I was using the ASCII mode which is primarily intented to handle information stored in text. Simply changing the mode to Binary and re-uploading the Zip file then allowed me to extract it successfully.

If you’re using a bit of software to transfer files then this setting will be in the preferences and will normally be set by default. In my scenario I was performing the upload using PHP so the following change was needed to correct the mode used:

ftp_put($conn, $remoteFile, $localFile, FTP_ASCII);


ftp_put($conn, $remoteFile, $localFile, FTP_BINARY);
Tags: , , ,
This entry was posted on Thursday, February 21st, 2013 at 11:26 am by +Steve Marks and is filed under Miscellaneous, PHP, Software, Web Development. You can follow any responses to this entry through the RSS 2.0 feed.

Fear not, we won't publish this

Comments (0)

No comments have been left yet. Be the first