时间:2021-07-01 10:21:17 帮助过:2人阅读
http://wiki.open.t.qq.com/index.php?oldid=4665&title=API%E9%8F%82%E5%9B%A8%E3%80%82/%E5%AF%B0%EE%86%BC%E5%B4%A5%E9%8E%BA%E3%83%A5%E5%BD%9B/%E9%8D%99%E6%88%A3%E3%80%83%E7%94%AF%EF%B9%80%EE%98%BF%E5%AF%AE%E7%8A%B2%E6%B5%98%E9%90%97%E5%9B%A9%E6%AE%91%E5%AF%B0%EE%86%BC%E5%B4%A5 这里有个列子。
有php代码,你给的地址如何看api源代码?
高手呢,怎么没人回复了,只需要api服务器端能把二进制流保存文件即可,或者图片都行
除去准备工作,不就一句 move_uploaded_file 吗?
如何通过api接口来上传?
请高手给点代码看看
谁的 API ?
高手们写个简单的api能上传图片即可
上传图片或者文件,那个简单就搞下,代码我看看案例,谢谢..................!
自己做个api服务器端上传文件用,不知道如何搞
和表单上传一样的写
http://www.w3school.com.cn/php/php_file_upload.asp
require_once "../common_mysql.php";require_once MESSAGE_PATH . 'zh/zh_calendar_message.php';require_once "function_common/user_function.php";require_once "function_common/public_function.php";global $DB;$sql_time = microtime ( true );//$uid = $self_userid;//保存图片$json_result ['status'] = 0;$path = 'upfile';$json_result ['status'] = 0;$json_result ['successmsg'] = '上传失败';if (isset ( $_FILES ['imageZip'] )) { $upfile = 'upfile/' . $_FILES ['imageZip'] ['name']; if (! @file_exists ( $path )) { @mkdir ( $path ); } $result = @move_uploaded_file ( $_FILES ['imageZip'] ['tmp_name'], $upfile ); if (! $result) { $json_result ['status'] = 0; $json_result ['successmsg'] = '上传失败'; $json_result ['datas'] = array ('savePath' => $upfile ); exit ( json_encode ( $json_result ) ); }}$json_result ['status'] = 1;$json_result ['datas'] = array ('savePath' => $upfile );
现在问题就是其他人如何把$_FILES通过curl给传过来?
难道只能这样吗?就不能用curl传过来吗?
$file = realpath('gif/1.gif'); //要上传的文件$fields['f'] = '@'.$file;$ch = curl_init(); curl_setopt($ch, CURLOPT_URL,"你的api接口"); curl_setopt($ch, CURLOPT_POST, 1 );curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);curl_exec ($ch); curl_close ($ch);
ok谢谢啊,我来试试,非常感谢