Jump to content

[SOLVED] CURL multipart/form-data upload


Thomisback

Recommended Posts

Hi,

 

I'm trying to post some variables and upload a picture with CURL, I have been searching for hours and i'm really stuck.

 

Part of my code:

$parameters = array("file" => "@test.jpg", "othervars" => "true");
etc...etc...
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $parameters);

The error I get is:

failed creating formpost data

 

It is this bit which causes the error:

"file" => "@test.jpg"

 

While the image is in the same folder!

Does anyone see what's wrong with my script?

Thanks a lot

Link to comment
https://forums.phpfreaks.com/topic/136099-solved-curl-multipartform-data-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.