php curl 上傳文件

<?phpphp


 

$post_data = [];json

$post_data['img'] = new CurlFile('./test.txt');curl

$url = 'http://127.0.0.1:9098/test.php';post


 

$ch = curl_init();url

curl_setopt($ch , CURLOPT_URL , $url);code

curl_setopt($ch , CURLOPT_RETURNTRANSFER, 1);it

curl_setopt($ch , CURLOPT_POST, true);test

curl_setopt($ch, CURLOPT_BINARYTRANSFER,true);im

curl_setopt($ch , CURLOPT_POSTFIELDS, $post_data);top

$output = curl_exec($ch);

curl_close($ch);

echo json_encode($output);

?>

相關文章
相關標籤/搜索