我想通過上傳圖片fetch()。我使用formData并成功上傳,但一次只能上傳一張圖片。handleGetNewPictureDragDrop = data => { console.log(data); const formData = new FormData(); for (let i = 0; i < data.length; i++) { formData.append('filename', data[i]); } console.log(...formData); const name = this.props.nameCategory; fetch('http://api.../gallery/' + name, { method: 'POST', body: formData, }) .then(response => response.json()) .then(success => console.log(success)) .catch(error => console.log(error)); }控制臺日志(數據):控制臺日志(...表單數據):控制臺日志(成功):我拍了 3 張圖片,創建formData,有 3 張圖片,但在發布后formData我只上傳了一張。
上傳多個文件/圖像,獲取,formData
POPMUISE
2022-12-22 13:00:42