User Tools

Site Tools


uphp:functions:ftp_open

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

uphp:functions:ftp_open [2020/05/06 04:05]
admin
uphp:functions:ftp_open [2021/09/13 05:57]
Line 1: Line 1:
-======ftp_open====== 
- 
-<badge>WM-MINI2, WM-MEGA FW >= 2.1137</badge> <badge>WM-M2 FW >= 3.1137</badge> 
- 
-Open a connection to an FTP server 
- 
-====Description==== 
- 
-<well size="sm"><html> 
-<span style="font-size:125%;color:green">int 
-<span style="color:black">ftp_open ( 
-<span style="color:green">string 
-<span style="color:blue">$host 
-<span style="color:black">, 
-<span style="color:green">int 
-<span style="color:blue">$port 
-<span style="color:black">, 
-<span style="color:green">string 
-<span style="color:blue">$username 
-<span style="color:black">, 
-<span style="color:green">string 
-<span style="color:blue">$password 
-<span style="color:black">[, 
-<span style="color:green">int 
-<span style="color:blue">$secure 
-<span style="color:black">] 
-<span style="color:black">[, 
-<span style="color:green">int 
-<span style="color:blue">$use_keepalive 
-<span style="color:black">] 
-<span style="color:black">[, 
-<span style="color:green">int 
-<span style="color:blue">$ignore_response 
-<span style="color:black">] 
-) 
-</html></well> 
- 
-Connect to the server and return the response code. 
- 
-====Parameters==== 
- 
-<html><b><span style="color:blue">$host<span style="color:black"></b>:  <b><span style="color:green">String<span style="color:black"></b> containing the host name or IP address of teh FTP server</html> 
- 
-<html><b><span style="color:blue">$port<span style="color:black"></b>:  <b><span style="color:green">Int<span style="color:black"></b> FTP port number</html> 
- 
-<html><b><span style="color:blue">$username<span style="color:black"></b>:  <b><span style="color:green">String<span style="color:black"></b> containing the FTP username</html> 
- 
-<html><b><span style="color:blue">$password<span style="color:black"></b>:  <b><span style="color:green">String<span style="color:black"></b> containing the FTP password</html> 
- 
-<html><b><span style="color:blue">$secure<span style="color:black"></b>:  <b><span style="color:green">Int<span style="color:black"></b> whether to use TLS (1) or not (0)</html> 
- 
-<html><b><span style="color:blue">$use_keepalive<span style="color:black"></b>:  <b><span style="color:green">Int<span style="color:black"></b> whether to send keepalive messages or not (1=yes)</html> 
- 
-<html><b><span style="color:blue">$ignore_reponse<span style="color:black"></b>:  <b><span style="color:green">Int<span style="color:black"></b> 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.</html> 
- 
-====Return Values==== 
- 
-<html><b><span style="color:green">int<span style="color:black"></b></html>:  Returns 1 if FTP connection was successful and 0 if it failed. 
- 
-====Example 1==== 
- 
-<code php> 
-<? 
- $res = ftp_open("ftp.myserver.com",21,"myuser","mypassword"); 
- if ($res) { 
- print("connected to FTP server!!"); 
- ftp_close(); 
- } 
-?> 
-</code> 
- 
-====Example 2==== 
-Upload a file to the server but don't wait for the response 
-<code php> 
-<? 
-        // 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 
-            $res=ftp_upload("server_filename.txt","/logs/local_filename.txt",0,1); 
-            if ($res==1) { 
-                print("File uploaded successfully"); 
-            } else { 
-                print("Error uploading the file"); 
-            } 
-            ftp_close(); 
- } 
- 
-?> 
-</code> 
-====See Also==== 
- 
-[[ftp_close()]] - Close an FTP connection 
- 
  
uphp/functions/ftp_open.txt · Last modified: 2021/09/13 05:57 (external edit)