LibCURL error while sending file to FTP / SSL site

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
cajedi
Forum Newbie
Posts: 2
Joined: Mon Mar 19, 2007 2:14 pm

LibCURL error while sending file to FTP / SSL site

Post by cajedi »

I'm trying to upload a file to an FTP site which is running FTP over SSL. It looks like the script is able to login to the site, but is unable to upload a file. here's the error message:

Curl Err no:7
Curl Error msg:Uploaded unaligned file size (0 out of 325 bytes)


Here's how my script looks:

Code: Select all

$uploadfile = "/tmp/testfile.txt";
$fp = fopen ($uploadfile, "r");

$cobj = curl_init();

curl_setopt($cobj, CURLOPT_URL, "ftp://usernameassword@ftp.test.com/testfile.txt");

curl_setopt($cobj, CURLOPT_RETURNTRANSFER,1);
curl_setopt($cobj, CURLOPT_VERBOSE, 1);
curl_setopt($cobj, CURLOPT_UPLOAD, 1);
curl_setopt($cobj, CURLOPT_INFILE, $fp);
curl_setopt($cobj, CURLOPT_TRANSFERTEXT, 1);
curl_setopt($cobj, CURLOPT_FTP_SSL, CURLFTPSSL_ALL);
curl_setopt($cobj, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($cobj, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($cobj, CURLOPT_INFILESIZE, filesize($uploadfile));

$error = curl_exec($cobj);
echo "Curl Err no:" . curl_errno($cobj);
echo "<br>Curl Error msg:" . curl_error($cobj);
curl_close($cobj);
exit;
Any help on resolving this error message will be greatly appreciated
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Do you not have the FTP extension?
cajedi
Forum Newbie
Posts: 2
Joined: Mon Mar 19, 2007 2:14 pm

Post by cajedi »

the FTP extension in PHP has not been enabled in my company; I checked with the IT team, and they are adamant that i have to use LibCurl
Post Reply