![]() |
#1 |
Registered User
Join Date: Apr 2013
Location: Sydney
Posts: 127
|
FTP upload with cURL.
PHP does have a FTP library, but you can also use cURL to upload files on a FTP server. Here is a working example:
// open a file pointer $file = fopen("/path/to/file", "r"); // the url contains most of the info needed $url = "ftp://username ![]() $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // upload related options curl_setopt($ch, CURLOPT_UPLOAD, 1); curl_setopt($ch, CURLOPT_INFILE, $fp); curl_setopt($ch, CURLOPT_INFILESIZE, filesize("/path/to/file")); // set for ASCII mode (e.g. text files) curl_setopt($ch, CURLOPT_FTPASCII, 1); $output = curl_exec($ch); curl_close($ch); |
![]() |
![]() |
![]() |
#2 |
Registered User
Join Date: Jul 2012
Posts: 507
|
Very nice brother thanks for this sharing. i was looking for this.
|
![]() |
![]() |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
ASP File upload | ncjbhd | ASP | 32 | 05-19-2015 12:01 AM |
How can we upload files in PHP? | noahwilson | PHP / mySQL | 4 | 11-05-2013 11:34 PM |
Need help with image upload and manipulation. | noahwilson | Programming General | 0 | 06-05-2013 09:36 PM |
How to upload things. | ncjbhd | PHP / mySQL | 1 | 11-08-2011 05:04 AM |
image upload | mjvndhsb | PHP / mySQL | 0 | 09-15-2011 12:39 AM |