首页 > 编程 > PHP > 正文

PHP Curl 上传文件

2019-11-09 20:26:36
字体:
来源:转载
供稿:网友

php Curl 上传文件

5.0以后的用法

public function upload_file_to_java($furl, $url){ $data = array( 'importfile' => new CURLFile(realpath($furl)) ); $ch = curl_init(); //curl_setopt($ch, CURLOPT_USERPWD, 'joe:secret'); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $return_data = curl_exec($ch); curl_close($ch); echo $return_data;}

服务器端接收

PRint_r($_POST);print_r($_FILES);
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表