Page 1 of 1

cURL Help (Again)

Posted: Sun Jan 08, 2006 5:45 am
by TS_Death_Angel
I've made some progress... after being unable to upload images using the normal POST method, I thought it'd be easier to just use the 'upload from URL' option. For those of you who don't remember what I was making, it's a script to upload images to ImageShack. Here's what I've got so far:

Code: Select all

<?

$url = 'http://imageshack.us/index.php';

$post = '-----------------------------158701408529245\r\n
Content-Disposition: form-data; name="uploadtype"\r\n
\r\n
on\r\n
-----------------------------158701408529245\r\n
Content-Disposition: form-data; name="fileupload"; filename=""\r\n
Content-Type: application/octet-stream\r\n
\r\n
\r\n
-----------------------------158701408529245\r\n
Content-Disposition: form-data; name="url"\r\n
\r\n
http://prefbar.mozdev.org/getsuite.png\r\n
-----------------------------158701408529245\r\n
Content-Disposition: form-data; name="MAX_FILE_SIZE"\r\n
\r\n
3145728\r\n
-----------------------------158701408529245\r\n
Content-Disposition: form-data; name="refer"\r\n
\r\n
\r\n
-----------------------------158701408529245\r\n
Content-Disposition: form-data; name="brand"\r\n
\r\n
\r\n
-----------------------------158701408529245\r\n
Content-Disposition: form-data; name="optimage"\r\n
\r\n
1\r\n
-----------------------------158701408529245\r\n
Content-Disposition: form-data; name="optsize"\r\n
\r\n
320x320\r\n
-----------------------------158701408529245--\r\n
';
	  
$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $url );       
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_POST, 1 );
curl_setopt($ch, CURLOPT_POSTFIELDS, $post );

$response = curl_exec( $ch );
echo $response;

?>
I think it works, but all it returns in the front page of one of the ImageShack servers. Any help? :)

Posted: Sun Jan 08, 2006 8:09 am
by Weirdan
\r, \n and every other backslashed sequence does not work in single quotes. Try double quotes and see if it work for your.

Posted: Sun Jan 08, 2006 8:25 am
by TS_Death_Angel
No luck... :(