當前位置:首頁 » 文件管理 » 通過介面上傳文件

通過介面上傳文件

發布時間: 2023-06-08 16:28:09

A. APICloud 社區api.ajax介面多個文件上傳怎麼傳參

通過post請求上傳,有兩種方式,跟form表單通過file標簽提交文件是一樣的。
1、一種是鍵值對的方式,也就是一個name對應一個file:
api.ajax({
url: 'http://host/upLoad',
method: 'post',
report:true,//回調上傳進度
data: {
files: {
file1: '/sdcard/a.png',
file2: '/sdcard/b.png',
file3: '/sdcard/信搭c.png',
}
}
}, function(ret, err) {
if (ret) {
console.log(JSON.stringify(ret));
} else {
console.log(JSON.stringify(err));
}
});

2、另外一種是上傳文件數組,這種方式你的游坦畢伺服器要配合做特殊的處理進行支持:
api.ajax({
url: 'http://host/upLoad',
method: 'post',
report:true,/神芹/回調上傳進度
data: {
files: {
images: ['/sdcard/a.png', '/sdcard/b.png', '/sdcard/c.png']
}
}
}, function(ret, err) {
if (ret) {
console.log(JSON.stringify(ret));
} else {
console.log(JSON.stringify(err));
}
});

熱點內容
開源代碼編譯不通 發布:2023-09-24 20:29:37 瀏覽:869
安卓引導式訪問 發布:2023-09-24 20:25:33 瀏覽:725
加密狗激活 發布:2023-09-24 20:15:10 瀏覽:903
php獲取當前頁url 發布:2023-09-24 20:14:59 瀏覽:228
linux下編譯安裝mysql 發布:2023-09-24 20:12:52 瀏覽:97
蘋果7p伺服器地址是什麼 發布:2023-09-24 20:10:13 瀏覽:977
登陸的sql語句 發布:2023-09-24 20:10:11 瀏覽:454
linuxc開發工具 發布:2023-09-24 20:04:20 瀏覽:410
蘋果6怎麼給軟體加密 發布:2023-09-24 19:49:33 瀏覽:310
什麼是9根伺服器 發布:2023-09-24 19:47:34 瀏覽:266