From b9d2aeb46c72c37b9b1abfc2ae5f13a1ba07fb2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=BCneyt=20=C5=9Eent=C3=BCrk?= Date: Sat, 15 Feb 2020 12:39:35 +0300 Subject: [PATCH] close #1195 and fixed all file upload issues. --- resources/assets/js/plugins/form.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/resources/assets/js/plugins/form.js b/resources/assets/js/plugins/form.js index 5402f39a7..3fcac67e3 100644 --- a/resources/assets/js/plugins/form.js +++ b/resources/assets/js/plugins/form.js @@ -229,7 +229,21 @@ export default class Form { submit() { this.loading = true; - axios[this.method](this.action, this.data()) + let data = this.data(); + let form_data = new FormData(); + + for (let key in data) { + form_data.append(key, data[key]); + } + + axios({ + method: this.method, + url: this.action, + data: form_data, + headers: { + 'Content-Type': 'multipart/form-data' + } + }) .then(this.onSuccess.bind(this)) .catch(this.onFail.bind(this)); }