Change language

PHP Ftp_set_option () function

ftp_set_option ($ftp_connection, $option, $value) 
Parameter:This function takes three parameter as above and described below:
  • $ftp_connection:Required. Indicates an existing FTP connection.
  • $option:required. Specifies a runtime parameter to set for an existing FTP connection. 
    Possible Values ​​$option:
    • FTP_TIMEOUT_SEC: Returns the timeout used for the network.
    • FTP_AUTOSEEK: It is enabled by default. Returns TRUE if this option is enabled, otherwise returns FALSE.
    • FTP_USEPASVADDRESS: If set to FALSE, PHP ignores the IP address returned by the FTP server in response to the PASV command and uses the IP address instead. address as a parameter to the ftp_connect() function.
  • $value:This parameter is required. Specifies the value of the option in the previous parameter.
Returned value:
  • On success:returns TRUE, i.e. the option can be set.
  • On failure:returns FALSE. A warning is also generated.
Notes :
  • This function is available for PHP 4.2.0 and above.
  • The following examples cannot be run in the online IDE. So try running PHP on some hosting server or localhost with the correct ftp server name.
Example :  
/ / Connect to FTP server 
// Use correct FTP server $ftp_server = "localhost" ;  
// use correct ftp username $ftp_username = "user" ;  
// Use correct FTP password matching
// to the ftp username $ftp_userpass = "user" ;  
// Setting up ftp connection $ftp_connection = ftp_connect ( $ftp_server ) or die ( "Could not connect to $ftp_server" ); if ( $ftp_connection ) { echo "successfully connected to the ftp server!" ; // Login to the established connection with // ftp user password $login = ftp_login ( $ftp_connection , $ftp_username , $ftp_userpass ); if ( $login ) { // Success check login echo "
logged in successfully!
; // Print setup successfully // for current ftp connection echo ftp_set_option ( $ftp_connection , FTP_TIMEOUT_SEC, 120); } else { echo "
login failed!"
; } // Close connection if (ftp_close ( $ftp_connection )) { echo "
Connection closed Successfully!"
; } }  
successfully connected to the ftp server! logged in successfully! 1 Connection closed Successfully! 


Best laptop for Sims 4


Best laptop for Zoom


Best laptop for Minecraft


Best laptop for engineering student


Best laptop for development


Best laptop for Cricut Maker


Best laptop for hacking


Best laptop for Machine Learning


Latest questions


psycopg2: insert multiple rows with one query

12 answers


How to convert Nonetype to int or string?

12 answers


How to specify multiple return types using type-hints

12 answers


Javascript Error: IPython is not defined in JupyterLab

12 answers


Python OpenCV | cv2.putText () method

numpy.arctan2 () in Python

Python | os.path.realpath () method

Python OpenCV | () method

Python OpenCV cv2.cvtColor () method

Python - Move item to the end of the list

time.perf_counter () function in Python

Check if one list is a subset of another in Python

Python os.path.join () method