Vue中的文件数组在Laravel控制器中返回空

时间:2019-05-11 03:41:37

标签: vue.js laravel-5.8

我目前正在处理多张图片,并且正在获取文件并将其存储到我的阵列中。但是当我返回所有请求时,我的数组返回空,图像文件未显示。

这是我的数据

data() {
    return {
        // ckeditor
        editor: ClassicEditor,
        bike_upload_photo: {
            assigned_bike_id: '',
            bike_description: '',
            photos: []
        },
        bike_photo_url: {
            first_photo: '',
            second_photo: '',
            third_photo: '',
            fourth_photo: '',
        },

    }
},

这就是我将图像文件存储在数组中的方式。

firstPhotoChange(e) {
        const first_photo_uploaded = e.target.files[0];
        this.bike_photo_url.first_photo = URL.createObjectURL(first_photo_uploaded);
        this.bike_upload_photo.photos.push(first_photo_uploaded);
    },      

    secondPhotoChange(e) {
        const second_photo_uploaded = e.target.files[0];
        this.bike_photo_url.second_photo = URL.createObjectURL(second_photo_uploaded);
        this.bike_upload_photo.photos.push(second_photo_uploaded);
    },

    thirdPhotoChange(e) {
        const third_photo_uploaded = e.target.files[0];
        this.bike_photo_url.third_photo = URL.createObjectURL(third_photo_uploaded);
        this.bike_upload_photo.photos.push(third_photo_uploaded);
    },

    fourthPhotoChange(e) {
        const fourth_photo_uploaded = e.target.files[0];
        this.bike_photo_url.fourth_photo = URL.createObjectURL(fourth_photo_uploaded);
        this.bike_upload_photo.photos.push(fourth_photo_uploaded);
    }

这是我第一次处理文件,但发现困难。请对我好。谢谢!

0 个答案:

没有答案