Skip to content

Instantly share code, notes, and snippets.

@mitrallex
Last active February 5, 2018 20:37
Show Gist options
  • Save mitrallex/a9cc2a5a767fa83e5819b6ce336faee7 to your computer and use it in GitHub Desktop.
Save mitrallex/a9cc2a5a767fa83e5819b6ce336faee7 to your computer and use it in GitHub Desktop.
laravel-file-hosting
endEditing(file) {
this.editingFile = {};
let formData = new FormData();
formData.append('name', file.name);
formData.append('type', file.type);
formData.append('extension', file.extension);
axios.post('files/edit/' + file.id, formData)
.then(response => {
if (response.data === true) {
this.showNotification('Filename successfully changed!', true);
var src = document.querySelector('[alt="' + file.name +'"]').getAttribute("src");
document.querySelector('[alt="' + file.name +'"]').setAttribute('src', src);
}
})
.catch(error => {
this.errors = error.response.data.errors;
this.showNotification(error.response.data.message, false);
});
this.fetchFile(this.activeTab, this.pagination.current_page);
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment