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

通過介面上傳文件

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

熱點內容
gs3選哪個配置好 發布:2025-05-09 17:43:07 瀏覽:386
sql2008ssms 發布:2025-05-09 17:42:21 瀏覽:445
微信登錄狀態怎麼知道密碼是什麼 發布:2025-05-09 17:40:08 瀏覽:344
搭建的雲免連接不上伺服器 發布:2025-05-09 17:40:05 瀏覽:846
跟庄漲停源碼 發布:2025-05-09 17:20:46 瀏覽:888
什麼叫緩存呢 發布:2025-05-09 17:20:45 瀏覽:318
sqlbegin 發布:2025-05-09 17:20:35 瀏覽:338
藍牙耳機源碼 發布:2025-05-09 17:18:24 瀏覽:264
自己搭建個人雲游戲伺服器 發布:2025-05-09 17:18:23 瀏覽:346
用編程美術 發布:2025-05-09 16:47:34 瀏覽:614