<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]);
}
}
?>
curl出现Deprecated: curl_setopt(): The usage of the @filename API for file uploading is deprecated. Pl
最新推荐文章于 2023-04-17 16:56:22 发布