I'm using curl and php to upload file. I need help to set a custom request header keys like
X-Filename blahblah.zip
X-Filesize 2677
X-Filetype application/zip
To send an HTTP header with a Curl request, you can use the -H command-line option and pass the header name and value in "Key: Value" format. If you do not provide a value for the header, this will remove the standard header that Curl would otherwise send. The number of HTTP headers is unlimited.
In the Home pane, double-click HTTP Response Headers. In the HTTP Response Headers pane, click Add... in the Actions pane. In the Add Custom HTTP Response Header dialog box, set the name and value for your custom header, and then click OK.
Next, we've set the CURLOPT_POST option to TRUE to set the request method to HTTP POST. Further, we need to use the CURLOPT_POSTFIELDS option to set the POST data that we want to submit along with the request. Finally, we've used the curl_exec function to execute the cURL request.
Parameters ¶ A cURL handle returned by curl_init(). The CURLOPT_XXX option to set. The value to be set on option .
You must use the curl_setopt()
function, and its CURLOPT_HTTPHEADER
option (quoting) :
An array of HTTP header fields to set, in the format
array('Content-type: text/plain', 'Content-length: 100')
Basically, in your case, you'd have something like this :
$headers = array(
'X-Filename: blahblah.zip',
'X-Filesize: 2677',
'X-Filetype: application/zip',
);
curl_setopt($your_resource, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('X-Filename: blahblah.zip', 'X-Filesize: 2677', 'X-Filetype: application/zip'));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With