如何使用 curl 和 PHP 设置自定义请求标头键?
我正在使用curl和php上传文件。我需要帮助来设置自定义请求标头键,例如
X-Filename  blahblah.zip
X-Filesize  2677
X-Filetype  application/zip
						我正在使用curl和php上传文件。我需要帮助来设置自定义请求标头键,例如
X-Filename  blahblah.zip
X-Filesize  2677
X-Filetype  application/zip
						您必须使用 curl_setopt() 函数及其CURLOPT_HTTPHEADER选项(引用):
要设置的 HTTP 标头字段的数组,格式为
array('Content-type: text/plain', 'Content-length: 100')
基本上,在你的情况下,你会有这样的东西:
$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'));