[solved] curl question

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
User avatar
potsed
Forum Commoner
Posts: 50
Joined: Sat Oct 09, 2004 12:00 pm
Location: - South Africa

[solved] curl question

Post by potsed »

Hi all seasons greets...

i have a question on cURL... The following code does everything its supposed to do ... upload an image file from my local machine to the web server. however when i look at the image on the server it does not show... although the filesizes are the same on both my local machine and on the server... does anyone know why this is happening... it only causes an error when it is an image file normal text files are fine...

Code: Select all

<?php
$curl = curl_init();
	$file = "file://path/to/image.jpg";
	$fp = fopen($file, "rb"); 
	curl_setopt($curl, CURLOPT_URL,"ftp://path/to/server/image.jpg");
	curl_setopt($curl, CURLOPT_USERPWD, "username:password");
	curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);  
	curl_setopt($curl, CURLOPT_UPLOAD, 1);  
	curl_setopt($curl, CURLOPT_INFILE, $fp);  
	curl_setopt($curl, CURLOPT_INFILESIZE, filesize($file));
	curl_setopt($curl, CURLOPT_FTPASCII, 1); 
	curl_exec($curl);  
	curl_close ($curl);
?>
Last edited by potsed on Sat Dec 25, 2004 7:07 am, edited 1 time in total.
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

you must set CURLOPT_FTPASCII to 0 when uploading binary files
User avatar
potsed
Forum Commoner
Posts: 50
Joined: Sat Oct 09, 2004 12:00 pm
Location: - South Africa

Post by potsed »

of course how stupid could i be.... thanks wierdan
Post Reply