Created
March 2, 2015 11:02
-
-
Save temberature/292daba2573d7fbdba68 to your computer and use it in GitHub Desktop.
php模拟提交表单
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//模拟POST上传文件 | |
$post = array('callbackurl' => '/idcard/', 'action' => 'idcard', 'img' => '@20070627114712.jpg'); //POST提交内容 | |
$url = "http://ocr.ccyunmai.com/UploadImg.action"; //上传地址 | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_URL, $url); //URL | |
curl_setopt($ch, CURLOPT_POST, 1); //模拟POST | |
curl_setopt($ch, CURLOPT_POSTFIELDS, $post); //POST内容 | |
// curl_setopt($ch, CURLOPT_HEADER, true); | |
$headers = array( | |
"Content-type: multipart/form-data; boundary=----WebKitFormBoundaryBPBGyBEblEzKm3Jx", | |
"Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8", | |
"Cache-Control: no-cache", | |
"Pragma: no-cache", | |
); | |
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); | |
var_dump(curl_exec($ch)); | |
echo "string"; | |
curl_close($ch); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment