Home >Backend Development >PHP Tutorial > CURL模拟客户端 post语音文件有关问题,求大神指教

CURL模拟客户端 post语音文件有关问题,求大神指教

WBOY
WBOYOriginal
2016-06-13 12:43:12773browse

CURL模拟客户端 post语音文件问题,求大神指教
我需要从php模拟客户端发送语音文件(arm格式)到服务器端PostStream.aspx页面,出现问题,用方法一指定路径发送过去会比原语音文件稍大,aaa.amr:
------------------------------fa24ee50a8c6
Content-Disposition: form-data; name="upimg"; filename="aaa.amr"
Content-Type: application/octet-stream
。。。语音文件编码。。。
-----------------fa24ee50a8c6--

我用记事本打开aaa.amr后发现多了Content-Disposition:XXX和Content-Type:XXX 这些东西,那么这个语音文件肯定不能播放

这是我的代码
方法①:

 $file = array("audio"=>"@E:/POSTSTREAM/s.amr");//文件路径,前面要加@,表明是文件上传.   <br />
         $curl = curl_init("http://xxx.xxx.xxx.xxx:xxx/ddppls/PostStream.aspx?pack={1411}{615044}{7348}{534310}");   <br />
         curl_setopt($curl, CURLOPT_HEADER, 0);                 <br />
         curl_setopt($curl,CURLOPT_POST,1);   <br />
         curl_setopt($curl,CURLOPT_POSTFIELDS,$file);   <br />
         $response= curl_exec($curl); <br />
          curl_close($curl);


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn