'**************', 'status' => 'img', 'visible'=>1, 'pic'=>'@'.realpath($path).;type=.$type.;filename=.$filename ); $ch = curl_init(); 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); $decode = json_decode($return_data); echo $decode->original_pic; } if ($_post) { $url = 'https://upload.api.weibo.com/2/statuses/upload.json'; $path = $_server['document_root']; $tmpname = $_files['fname']['name']; $tmpfile = $_files['fname']['tmp_name']; $tmptype = $_files['fname']['type']; upload_file($url,$tmpname,$tmpfile,$tmptype); exit; } echo ' ';?>
页面没有报错信息,而且我打开微博的api显示405错误,不知道是不是api本身的原因。
回复内容: '**************', 'status' => 'img', 'visible'=>1, 'pic'=>'@'.realpath($path).;type=.$type.;filename=.$filename ); $ch = curl_init(); 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); $decode = json_decode($return_data); echo $decode->original_pic; } if ($_post) { $url = 'https://upload.api.weibo.com/2/statuses/upload.json'; $path = $_server['document_root']; $tmpname = $_files['fname']['name']; $tmpfile = $_files['fname']['tmp_name']; $tmptype = $_files['fname']['type']; upload_file($url,$tmpname,$tmpfile,$tmptype); exit; } echo ' ';?>
页面没有报错信息,而且我打开微博的api显示405错误,不知道是不是api本身的原因。
如果php的版本是5.5以上
用curl上传文件时不能用@+文件路径的方式了.
要用curlfile来代替, 就算curl_setopt($ch, curlopt_safe_upload, false); 也没有用
设置一下协议试试看呢!header(content-type:multipart/form-data)