Jump to content

cURL FTP won't upload


myron

Recommended Posts

I'm using a PHP/cURL script to upload a file from my server at GoDaddy to Shopzilla.  It looks like it's working, but no file actually gets uploaded.  I know my login name and password are correct because I can use them in FileZilla and they work fine;that's how I'm checking the upload to make sure it actually happened.  Here's the code I'm using:

[code]<?php
$URL="ftp://username:[email protected]";  //  ftp address to Shopzilla
echo "Destination: ".$URL."<br>\n";
$OutFile = "***server path here***/feeds/shopzilla.txt";  //  path to file to upload
echo "Source: ".$OutFile."<br>\n";
echo "Start cURL script...<br>\n";
$ch = curl_init();  //  start curl process
echo "Open file...<br>\n";
$fp = fopen ($OutFile, "r");  //  open the file to read
echo "Setting cURL options...<br>\n";
// upload the file
curl_setopt($ch, CURLOPT_VERBOSE, 1); // to output verbose information
curl_setopt ($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);  // is default anyway...
curl_setopt ($ch, CURLOPT_PROXY,"http://proxy.shr.secureserver.net:3128");  //  GoDaddy's proxy server
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE);  //  to stop CURL from verifying the peer's certificate
curl_setopt($ch, CURLOPT_URL, $URL); //  The URL to fetch
curl_setopt ($ch, CURLOPT_TIMEOUT, 360);  //  The maximum number of seconds to allow CURL functions to execute
curl_setopt($ch, CURLOPT_UPLOAD, 1);  // TRUE to prepare for an upload
curl_setopt($ch, CURLOPT_INFILE, $fp);  //  The file that the transfer should be written to
// set size of the file, which isn't _mandatory_ but helps libcurl to do
// extra error checking on the upload.
curl_setopt($ch, CURLOPT_INFILESIZE, filesize($OutFile));
echo "Uploading file...<br>\n";
echo "Check for errors...<br>\n";
$error = curl_exec ($ch);
// check $error here to see if it did fine or not!
curl_close ($ch);
echo "<br>Close cURL - process complete<br>\n";
?>[/code]

Here's the results:

[quote]Destination: ftp://username:[email protected]
Source: ***Server Path Here***/feeds/shopzilla.txt
Start cURL script...
Open file...
Setting cURL options...
Uploading file...
Check for errors...

--------------------------------------------------------------------------------
Operation successful
File created

Generated Thu, 11 Jan 2007 23:38:50 GMT by wc04.inet.mesa1.secureserver.net (squid/2.5.STABLE12)
--------------------------------------------------------------------------------

Close cURL - process complete[/quote]
Link to comment
https://forums.phpfreaks.com/topic/33831-curl-ftp-wont-upload/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.