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

来源:互联网 发布:索尼xzp挂起网络 编辑:程序博客网 时间:2024/06/08 05:37
<pre name="code" class="php"><?phpclass 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]);}}?>


                                             
0 0
原创粉丝点击