Go Back   Site Owners Forums - Webmaster Forums > Search Engine Optimization > Search Engine Optimization

Notices


Reply
 
Thread Tools Rate Thread Display Modes
Old 07-27-2013, 03:38 AM   #1
binarynpixel
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[email protected]:21/path/to/new/file";

$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);
binarynpixel is offline   Reply With Quote

Old 07-28-2013, 09:27 PM   #2
terrijhon
Registered User
 
Join Date: Jul 2012
Posts: 507
Very nice brother thanks for this sharing. i was looking for this.
terrijhon is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
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


All times are GMT -7. The time now is 08:37 PM.


Powered by vBulletin Copyright © 2020 vBulletin Solutions, Inc.