PHPcurl 模拟 form表单提交

2020-3-11 流沙 PHP

测试go结构, 同事模拟curl 一直过不去


测试可行的代码


<?php
$ch = curl_init();
$path = dirname(__FILE__)."/404.jpg";

$post_data = array(
                'path'=>'accessory20200310170042',
				'rename'=>'1',
				'path_type'=>'0',
                'files[]'=>new CURLFile($path)
            );
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_POST, true);  
curl_setopt($ch,CURLOPT_BINARYTRANSFER,true);
curl_setopt($ch, CURLOPT_POSTFIELDS,$post_data);
curl_setopt($ch, CURLOPT_URL, 'http://localhost:3001/upload/files?app_id=xxxx&timestamp=1111&token=22222');
$info= curl_exec($ch);
curl_close($ch);
   
print_r($info);

?>

发表评论:

Powered by 流沙团

备案号:鄂ICP备15017378号-1