脚本宝典收集整理的这篇文章主要介绍了php – 是否可以使用cURL使用POST流上传文件?,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
// URL on which we have to post data $url = "http://localhost/tutorials/post_action.PHP"; // Any other field you might want to catch $post_data['name'] = "khan"; // File you want to upload/post $post_data['file'] = "@c:/LOGs.log"; // InITialize cURL $ch = curl_init(); // Set URL on which you want to post the Form and/or data curl_setopt($ch,CURLOPT_URL,$url); // Data+Files to be posted curl_setopt($ch,CURLOPT_POSTFIELDS,$post_data); // Pass TRUE or 1 if you want to wait for and catch the response against the request made curl_setopt($ch,CURLOPT_RETURNtransfer,1); // For Debug mode; shows up any error encountered during the operation curl_setopt($ch,CURLOPT_VERBOSE,1); // Execute the request $response = curl_exec($ch); // Just for debug: to see response echo $response;
以上是脚本宝典为你收集整理的php – 是否可以使用cURL使用POST流上传文件?全部内容,希望文章能够帮你解决php – 是否可以使用cURL使用POST流上传文件?所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。