- 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_nb_put() function in PHP
The ftp_nb_put() function uploads a file to the FTP server.
Syntax
ftp_nb_put(con,remote_file,local_file,transfer_mode,beg_pos);
Parameters
con − The FTP connection
remote_file − The file to upload to
local_file − The local file path to upload
transfer_mode − This is the transfer mode. The following are the possible values:
- FTP_ASCII, or
- FTP_BINARY
beg_pos − The position to begin the downloading
Return
The ftp_nb_put() function returns any of the following values −
FTP_FAILED − send/receive failed
FTP_FINISHED − send/receive completed
FTP_MOREDATA − send/receive in progress
Example
The following is an example −
<?php $ftp_server = "192.168.0.4"; $ftp_user = "jacob"; $ftp_pass = "tywg61gh"; $con = ftp_connect($ftp_server) or die("Could not connect to $ftp_server"); $login = ftp_login($con, $ftp_user, $ftp_pass); $local_file = "new.txt"; $my_serverfile = "serverfile.txt"; $c = ftp_nb_put($con, $my_serverfile, $local_file, FT_BINARY) while ($c == FTP_MOREDATA) { // continue downloading $c = ftp_nb_continue($con); } if ($c != FTP_FINISHED){ echo "Error downloading the server file!"; exit(1); } // close ftp_close($con); ?>
Advertisements