WM-MINI2, WM-MEGA FW >= 2.1137 WM-M2 FW >= 3.1137

Open a connection to an FTP server


int ftp_open ( string $host , int $port , string $username , string $password [, int $secure ] [, int $use_keepalive ] [, int $ignore_response ] )

Connect to the server and return the response code.


$host: String containing the host name or IP address of teh FTP server

$port: Int FTP port number

$username: String containing the FTP username

$password: String containing the FTP password

$secure: Int whether to use TLS (1) or not (0)

$use_keepalive: Int whether to send keepalive messages or not (1=yes) [only on FW > x.1169]

$ignore_reponse: Int set to 1 if your FTP uploads are not completing properly, this will not wait for the 226 response confirmation but instead close the connection once the data socket has finished sending data to the server. [only on FW > x.1169]

Return Values

int: Returns 1 if FTP connection was successful and 0 if it failed.

Example 1

	$res = ftp_open("ftp.myserver.com",21,"myuser","mypassword");
	if ($res) {
		print("connected to FTP server!!");

Example 2

Upload a file to the server but don't wait for the response

        // set folder path here
        $folder_path = "/web/";
	$res = ftp_open("ftp.myserver.com",21,"myuser","mypassword",0,1,1);
	if ($res) {
            print("connected to FTP server!!");
            $res=ftp_command("cwd ".$folder_path);
            // upload the file
            if ($res==1) {
                print("File uploaded successfully");
            } else {
                print("Error uploading the file");

See Also

ftp_close() - Close an FTP connection