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

通過介面上傳文件

發布時間: 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));
}
});

熱點內容
java返回this 發布:2025-10-20 08:28:16 瀏覽:603
製作腳本網站 發布:2025-10-20 08:17:34 瀏覽:895
python中的init方法 發布:2025-10-20 08:17:33 瀏覽:589
圖案密碼什麼意思 發布:2025-10-20 08:16:56 瀏覽:774
怎麼清理微信視頻緩存 發布:2025-10-20 08:12:37 瀏覽:694
c語言編譯器怎麼看執行過程 發布:2025-10-20 08:00:32 瀏覽:1020
郵箱如何填寫發信伺服器 發布:2025-10-20 07:45:27 瀏覽:264
shell腳本入門案例 發布:2025-10-20 07:44:45 瀏覽:123
怎麼上傳照片瀏覽上傳 發布:2025-10-20 07:44:03 瀏覽:814
python股票數據獲取 發布:2025-10-20 07:39:44 瀏覽:722