![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
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_put() function in PHP
The ftp_put() function uploads a file to the FTP server.
Syntax
ftp_put(con,remote_file,local_file,mode,beg_pos);
Parameters
con − The FTP connection
remote_file − The file path to upload to
local_fil − The path of the file to upload
mode − The transfer mode. The following are the possible value −
FTP_ASCII, or
FTP_BINARY
beg_pos − The position to start uploading
Return
The ftp_put() function returns TRUE on success or FALSE on failure.
Example
The following is an example that uploads a file to the server −
<?php $ftp_server = "192.168.0.4"; $ftp_user = "tim"; $ftp_pass = "wthbn#@121"; $con = ftp_connect($ftp_server) or die("Could not connect to $ftp_server"); $login = ftp_login($con, $ftp_user, $ftp_pass); $local_file = "localfile.txt"; $my_serverfile = "serverfile.txt"; if (ftp_put($ftp_conn, $my_serverfile, $local_file, FTP_ASCII)){ echo "File uploaded!"; } else { echo "Error in uploading the file!"; } // close ftp_close($con); ?>
Advertisements