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

通過介面上傳文件

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

熱點內容
sqlsaserver 發布:2025-09-14 07:44:42 瀏覽:960
pythonif寫一行 發布:2025-09-14 07:41:39 瀏覽:993
lua存儲數據 發布:2025-09-14 07:33:05 瀏覽:111
教你如何選配置車 發布:2025-09-14 07:32:21 瀏覽:417
行李箱自帶的密碼是多少 發布:2025-09-14 07:27:40 瀏覽:278
ps2020版本怎麼調整存儲盤 發布:2025-09-14 07:20:28 瀏覽:860
奧迪a6哪個配置最保值 發布:2025-09-14 07:11:53 瀏覽:986
android查看文件 發布:2025-09-14 07:00:37 瀏覽:291
carlyle壓縮機 發布:2025-09-14 06:16:51 瀏覽:978
支持ftp免費空間 發布:2025-09-14 06:05:16 瀏覽:208