Home > Backend Development > PHP Tutorial > php怎么做api上传文件接口

php怎么做api上传文件接口

WBOY
Release: 2016-06-13 12:05:18
Original
2701 people have browsed it

php如何做api上传文件接口?
现在要是实现上传wav,jpg等文件上传api接口,怎么上传,请高手们提供代码参考
------解决方案--------------------
http://www.w3school.com.cn/php/php_file_upload.asp
------解决方案--------------------

$file = realpath('gif/1.gif'); //要上传的文件<br />$fields['f'] = '@'.$file;<br /><br />$ch = curl_init();  <br />curl_setopt($ch, CURLOPT_URL,"你的api接口");  <br />curl_setopt($ch, CURLOPT_POST, 1 );<br />curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);<br /><br />curl_exec ($ch);  <br />curl_close ($ch);  <br />
Copy after login

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template