您的位置:首页 > 运维架构

curl出现Deprecated: curl_setopt(): The usage of the @filename API for file uploading is deprecated. Pl

2016-06-28 16:05 609 查看
<pre name="code" class="php"><?php
class IPTest extends PHPUnit_Framework_TestCase{
public function testUpload01(){
$file = __DIR__.'\assets\test.txt';
$post['file'] = '@'.$file;//非 PHP5.5
//$post['file'] = new CurlFile($file);//PHP 5.5
$ch = curl_init();

curl_setopt($ch, CURLOPT_HEADER, false);
//启用时会发送一个常规的POST请求,类型为:application/x-www-form-urlencoded,就像表单提交的一样。
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch,CURLOPT_BINARYTRANSFER,true);
curl_setopt($ch, CURLOPT_POSTFIELDS,$post);
curl_setopt($ch, CURLOPT_URL, $GLOBALS['UPLOAD_URL']);
$info= curl_exec($ch);
curl_close($ch);
if(curl_error($ch))
{
$this -> assertTrue(false);
}
$res = json_decode($info, true);
$this->assertEquals($except,$res[0]);
}
}
?>



                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: