Posting images via CURL to a form?

If you change the following block of code: from if (is_array($data) && count($data)>0){ curl_setopt($ch, CURLOPT_POST, true); $params = http_build_query($data); curl_setopt($ch, CURLOPT_POSTFIELDS, $params); } // to if (is_array($data) && count($data)>0) { curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); } And to have it post the file uploaded by the user, set up your data array like this: make sure $_FILES'file' has been uploaded and is valid $data = array('field' => 'value', 'name' => 'test', 'email' => 'something', 'file' => '@' . $_FILES'file''tmp_name' ); fetch($url, $username, $data) That will tell curl to send a form post with a file upload. By setting the post fields to an array and prepending an & to the full path of a file that is a value of the array, curl will send an multipart/form-data post request with your file upload See curl file upload example.

If you change the following block of code: // from if (is_array($data) && count($data)>0){ curl_setopt($ch, CURLOPT_POST, true); $params = http_build_query($data); curl_setopt($ch, CURLOPT_POSTFIELDS, $params); } // to if (is_array($data) && count($data)>0) { curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); } And to have it post the file uploaded by the user, set up your data array like this: // make sure $_FILES'file' has been uploaded and is valid $data = array('field' => 'value', 'name' => 'test', 'email' => 'something', 'file' => '@' . $_FILES'file''tmp_name' ); fetch($url, $username, $data); That will tell curl to send a form post with a file upload. By setting the post fields to an array and prepending an & to the full path of a file that is a value of the array, curl will send an multipart/form-data post request with your file upload.

See curl file upload example.

E.g. Site.Com/image. Jpg?

– Saulius Antanavicius Sep 22 at 17:25 The manual doesn't specify, it says to use the full path to the URL2 may be that php will try to fetch the image from the url if allow_url_fopen is turned on in php. Ini but I am not sure. You could try and see if that works.

– drew010 Sep 22 at 18:48 doesn't seem to be working, the site is in aspx, when I send the image field as an extra post with absolute path to the image, it just return blank... may this be because of field count? – Saulius Antanavicius Sep 23 at 19:46 worked in the end even tho aspx was producing errors, thanks! – Saulius Antanavicius Sep 23 at 20:01.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions