The following command returns true and uploads the text XML file to the FTP server:
if (ftp_put($this->ftpConnectionId, $this->remoteXmlFileName, $this->localXmlFileName, FTP_ASCII)) {
However, when I try to upload a .zip file intead of a text XML file, it still returns true but does not upload the file:
if (ftp_put($this->ftpConnectionId, $this->remoteXmlFileName, $this->localXmlFileName, FTP_BINARY)) {
I found that if I simply rename the zip file to “.xml”, it WILL upload the file but the .zip file is corrupted.
But if I rename the zip file to “.zip.xml” it again returns true but does not upload the file.
What could be the reasons for this odd behavior?
Additional Info:
A zip file can be uploaded via FileZilla no problem with the same account.
I also am specifing:
ftp_pasv($this->ftpConnectionId, true);
A zipfile is a binary file. That’s probably why uploading it as .xml corrupts the file. Try specifying FTP_BINARY instead of FTP_ASCII. FTP_BINARY will work for ascii files too, but not vice versa, so you can better always use FTP_BINARY than always FTP_ASCII.
The ftp server may reject the file for many reasons, so it may allow the upload at first, but then not save the file. The ascii/binary problem may be one, but also some file extensions may be blacklisted, or the file could be too big. The latter is unlikely, though, since uploading the zipfile with a different extensions worked for you.
I think the ftp server actively ignores zip files.