淘宝TFS RESTful API 调用


   
  <?php
  
echo " PHP_SAPI : " , PHP_SAPI , "PHP_VERSION : " , phpversion() , "ZEND_VERSION: " , zend_version() , "PHP_OS : " , PHP_OS , " - " , php_uname() , "INI actual : " , realpath(get_cfg_var("cfg_file_path")) , "More .INIs : " , (function_exists('php_ini_scanned_files') ? str_replace("\n","", php_ini_scanned_files()) : "** not determined **");

$url = 'http://169.57.13.186:8080/v1/tfs' ;
$fields['filelist'] = '@'.'D:\WWW\cl.jpg';
//$post_data = implode('&',$fields);

//open connection
$ch = curl_init() ;
//set the url, number of POST vars, POST data
curl_setopt($ch, CURLOPT_URL,$url) ;
curl_setopt($ch, CURLOPT_POST,count($fields)) ; // 启用时会发送一个常规的POST请求,类型为:application/x-www-form-urlencoded,就像表单提交的一样。
curl_setopt($ch, CURLOPT_POSTFIELDS,$fields); // 在HTTP中的“POST”操作。如果要传送一个文件,需要一个@开头的文件名

ob_start();
curl_exec($ch);
$result = ob_get_contents() ;
ob_end_clean();

echo $result;

//close connection
curl_close($ch) ;

?>

我这里有段代码是提交给淘宝TFS 图片服务器的, 能够提示图片上传了,反悔了18位识别码,但是访问这个识别码是显示 http://img1.comprame.com/v1/tfs/T10yh...
显示的却是
--------------------------519d3f8393e84370
Content-Disposition: form-data; name="filelist"; filename="D:\WWW\cl.jpg"
Content-Type: application/octet-stream

--------------------------519d3f8393e84370--

如何让提交的图片能直接显示图片呢?
这个是服务器上手动上传的http://img1.comprame.com/v1/tfs/T1btJTByJT1RCvBVdK

php

炎D妖精诺露琪 8 years, 10 months ago

Your Answer