How to update image/file
ShekhSaifuddin007 opened this issue · comments
I'm using this vfom
I'm successfully creating data with image but when going to update it's not gonna update my image here is my code
for creating (Successfull)
onFileSelected(event) {
let file = event.target.files[0];
this.form.image = file;
},
store() {
this.$Progress.start();
this.form.busy = true;
this.form.post('/api/students', {
transformRequest: [function (data, headers) {
return objectToFormData(data)
}],
}).then(response => {
//do something
})
updating (Can't update image)
edit(data) {
this.editMode = true;
this.clearForm();
this.form.fill(data);
$('#modal').modal('show');
},
update() {
this.$Progress.start();
this.form.busy = true;
this.form.patch('/api/students/' + this.form.id)
.then(response => {
//do something
})
I'm also experiencing this problem, I'm fairly new in Vue and javascript. Anyone?
@ShekhSaifuddin007 Have you checked this issue? #56
@sironronron yeh, I saw that but did not solve my problem.😢😢
@sironronron Ohh, it's done by doing this
code
update() {
this.$Progress.start();
this.form.busy = true;
this.form.post('/api/students/' + this.form.id, {
transformRequest: [function (data, headers) {
data['_method'] = 'PUT' or 'PATCH';
return objectToFormData(data)
}],
})
.then(response => {
//whatever.....
})