Sabbir345's avatar

image Upload

I have a four image upload field in one page. now I’m facing a problem. . when i am upload an image they are store in one array but how to recognize which image which field. please help me

i think its need to be key value pair but how ?

<input type="file" @change="profileImage" /> <input type="file" @change="p1Certificate" /> <input type="file" @change="p2Certificate" /> <input type="file" @change="p3Certificate" />

0 likes
7 replies
nsvetozarevic's avatar

Don't you have different handlers for each input field? But if you do upload them by form giving them name attribute would help

Sabbir345's avatar

can you give me example please. if you don't mind

Sabbir345's avatar
export default {

    data () {

        return {
         
             user:{
                
                photo : '',
                p1certificate:'',
                p2certificate:'',
                p3certificate:'',

            },
        }
},
 methods:{

        profileImage(e){

            this.user.photo = e.target.files[0];

        },
     p1Certificate(e){

            this.user.p1certificate = e.target.files[1];

        },
    p2Certificate(e){

            this.user.p2certificate = e.target.files[2];

        },
   p3Certificate(e){

            this.user.p3certificate = e.target.files[3];

        },

}

faizaltkl's avatar

@Sabbir345

you can upload four image using the name field of each input type?did you tried this one?

Please or to participate in this conversation.