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

通過介面上傳文件

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

熱點內容
android橫屏生命周期 發布:2025-09-14 05:55:27 瀏覽:408
金稅盤密碼重置口令多少 發布:2025-09-14 05:55:19 瀏覽:341
pythonfor多線程 發布:2025-09-14 05:53:56 瀏覽:986
如何把軟體復制到伺服器 發布:2025-09-14 05:50:13 瀏覽:3
oracle的存儲過程和函數的區別 發布:2025-09-14 05:40:28 瀏覽:757
linux復制重命名 發布:2025-09-14 05:28:08 瀏覽:441
解壓泥推薦 發布:2025-09-14 05:15:15 瀏覽:397
伺服器屏蔽電腦外網無線連接 發布:2025-09-14 05:09:01 瀏覽:101
免費淘客源碼 發布:2025-09-14 04:59:02 瀏覽:729
一對一教編程 發布:2025-09-14 04:48:36 瀏覽:611