Friday, October 30, 2009

IIS 7 PHP FTP permissions error with ftp_nlist() and ftp_rawlist()

How `bout this! Two posts on my first day on the blog.

This one I encountered soon after finally getting my SSL up and running. In IIS 7, PHP my have some permission errors that will allow an FTP connection to go through, but as soon as you call ftp_nlist or ftp_rawlist, the script keeps running and causes a 500 Server Error.

Well, the simple solution is to force passive mode. Call this after connecting to the FTP.

ftp_pasv($conn_id, true);

Now, this might not be the best solution for you, especially if you're connecting to a typically stupid Windows Server 2008 that does not easily allow passive FTP, but it worked for me; so, if this doesn't work for you, just go punch the insensitive loudmouth sitting next to you .