5

how to send Request Payload with php cURL?

I'm trying to upload a file to a server that hosts files for free, and when sending the file to curl not I accept it and I redirected to an error page, and when I do it from your Interfas I can see how the files are sent in code inspector

How should I set cURL php for the file server receives me this way as if the browser?

Request Payload

------WebKitFormBoundary0cHZePmuSA0mtcdO

Content-Disposition: form-data; name="files[]"; filename="vlcsnap-2015-07-17-22h57m13s909.png" Content-Type: image/png

------WebKitFormBoundary0cHZePmuSA0mtcdO--

$ch = curl_init();

$ch_file = new CURLFile( $tmp_name, $type, $name );
$data = array("files[]"=>$ch_file);

curl_setopt($ch, CURLOPT_URL, "http://url_site.com");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);

$response = curl_exec($ch);
taylorUR
  • 63
  • 2
  • 6

0 Answers0