在PHP cURL中设置FTP模式

I have some code that is using the PHP cURL library to upload some files via FTP.

I've been told to switch the FTP mode from passive to active, but I can't find how to do that - there doesn't seem to be an option in the documentation relating to it. I'm not actually sure what mode it is currently using, or how I can view that.

The answer to this question is to use:

$curl = curl_init()
curl_setopt($curl, CURLOPT_FTP_USE_EPRT, true);

this will allow you to do Active ftp uploads.

Why are you using cURL? PHP has a set of FTP functions:

http://php.net/manual/en/book.ftp.php

As I understand it, the difference between passive and active ftp is that passive always uses the same port while active allows the client to specify the port that the server replies on.

From the CURL man page:

If you want to switch to active mode you need to use -P/--ftp-port

I think this corresponds to setting the CURLOPT_FTPPORT option.

With all that in mind, you'd be better off using the FTP functions (as MetaCipher says)