为什么我的cURL上传文件被forti防火墙检测为IPS攻击:
function post_files($url, $files,$data=array()) {
if (!is_array($files)) {
//Convert to array
$files[] = $files;
}
$n = sizeof($files);
for ($i = 0; $i < $n; $i++) {
$data['file' + $i] = "@" . $files[$i];
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
$response = curl_exec($ch);
return $response;
}
有没有卷曲选项?
答案 0 :(得分:2)
有了这个,似乎请求来自firefox:
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 5.1) AppleWebKit/535.6 (KHTML, like Gecko) Chrome/16.0.897.0 Safari/535.6');
有了这个,上传似乎来自实际网站:
curl_setopt ($ch, CURLOPT_REFERER, "http://domain you should have come from");