I want to upload multiple image using vuejs but in inspect it show in the picture :
{image.0: Array(1)}
image.0
:
['The image.0 field is required.']
[[Prototype]]
:
Object
this is my code:
const form = ref({
asset_item_id: '',
image_url: [],
note: '',
value: '',
unit: '',
usercode: '',
})
const addLogAsset = async() => {
if(loading.value) return
console.log('add Log asset')
loading.value = !loading.value
try{
const res = await $api('/api/a/add/itemtrack', {
method: 'POST',
body: {
asset_item_id: form.value.asset_item_id,
image: form.value.image_url,
note: form.value.note,
value: form.value.value,
unit: form.value.unit,
usercode: form.value.usercode,
},
onResponseError({ response }){
console.log('onResponseError', response)
},
})
const { status, data, message } = res
if(status == "OK"){
dialog.value = false
emits('updateDone', true)
form.value.asset_item_id = ''
form.value.image_url = []
form.value.note = ''
form.value.value = ''
form.value.unit = ''
form.value.usercode = ''
}else{
emits('updateErr', message)
console.log(message)
}
loading.value = false
}catch(err){
console.log(err)
loading.value = false
}
}
this is my template:
<v-file-input
v-model="form.image_url"
label="Photo"
variant="filled"
multiple
></v-file-input>
I think my laravel code has no problem because I have tried with postman and it work succesfully. I think it problem with my frontend. I hope you guys can help me 🙂
New contributor
Nur Eizaz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.