- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
ftp_connect() function in PHP
The ftp_connect() function opens an FTB connection.
Syntax
ftp_connect(host,port,timeout);
Parameters
host − The FTP server to connect to
port − The port of the FTP server. The default is 21. The host can be a domain or IP address.
timeout − The timeout for network operation
Return
The ftp_connect() function returns an FTP stream on success or FALSE on error
Example
The following is an example: to open an FTP connection, to work in it and closing it.
<?php $ftp_server="192.168.0.4"; $ftp_user="amit"; $ftp_pass="tywg61gh"; $con = ftp_connect($ftp_server); $res = ftp_login($con, $ftp_user, $ftp_pass); ftp_chdir($con, 'demo'); echo ftp_pwd($con); if (ftp_cdup($con)) { echo "Directory changed!
"; } else { echo "Directory change not successful!
"; } echo ftp_pwd($con); ftp_close($con); ?>
Advertisements