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

通過介面上傳文件

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

熱點內容
scratch少兒編程課程 發布:2025-04-16 17:11:44 瀏覽:628
榮耀x10從哪裡設置密碼 發布:2025-04-16 17:11:43 瀏覽:357
java從入門到精通視頻 發布:2025-04-16 17:11:43 瀏覽:76
php微信介面教程 發布:2025-04-16 17:07:30 瀏覽:300
android實現陰影 發布:2025-04-16 16:50:08 瀏覽:788
粉筆直播課緩存 發布:2025-04-16 16:31:21 瀏覽:338
機頂盒都有什麼配置 發布:2025-04-16 16:24:37 瀏覽:204
編寫手游反編譯都需要學習什麼 發布:2025-04-16 16:19:36 瀏覽:801
proteus編譯文件位置 發布:2025-04-16 16:18:44 瀏覽:357
土壓縮的本質 發布:2025-04-16 16:13:21 瀏覽:583