Skip to content

Instantly share code, notes, and snippets.

@mitrallex
Created February 5, 2018 11:59
Show Gist options
  • Save mitrallex/c8df192c3a89cb25ef76488d1f124866 to your computer and use it in GitHub Desktop.
Save mitrallex/c8df192c3a89cb25ef76488d1f124866 to your computer and use it in GitHub Desktop.
laravel-file-hosting
submitForm() {
this.formData = new FormData();
this.formData.append('name', this.fileName);
this.formData.append('file', this.attachment);
axios.post('files/add', this.formData, {headers: {'Content-Type': 'multipart/form-data'}})
.then(response => {
this.resetForm();
this.showNotification('File successfully upload!', true);
this.fetchFile(this.activeTab);
})
.catch(error => {
this.errors = error.response.data.errors;
this.showNotification(error.response.data.message, false);
this.fetchFile(this.activeTab);
});
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment