راکت
حل شده

آپلود عکس با لاراول و vue js

5 پاسخ

سلام خدمت دوستان
من می خواستم با استفاده از vue و لاراول اپلود تصویر انجام بدم.
در حال حاضر اطلاعات دیگه به خوبی ذخیره میشود اما فایل تصویر خیر .
لطفا اگر کد در مورد اپلود تصویر با لاراول و ویو دارید بفرستین و اگر راهنمایی هست ممنون میشم کمکم کنید.
@ali.bayat
@juza۶۶
@hesammousavi
@Alimotreb
کد ویو برای ذخیر و ویرایش input های دیگر
"

data: {
    items: [],
    hasError: true,
    hasDeleted: true,
    hasAgeError: true,
    showModal: false,
    e_name: '',
    e_age: '',
    e_id: '',
    e_profession: '',
    newItem: { 'name': '','age': '','profession': '' },
},
mounted: function mounted() {
    this.getVueItems();
},
methods: {
    getVueItems: function getVueItems() {
        var _this = this;

        axios.get('/readitemss').then(function (response) {
            _this.items = response.data;
        });
    },
    setVal(val_id, val_name, val_age, val_profession) {
        this.e_id = val_id;
        this.e_name = val_name;
        this.e_age = val_age;
        this.e_profession = val_profession;
    },

    createItem: function createItem() {
        var _this = this;
        var input = this.newItem;

        if (input['name'] === '' || input['age'] === '' || input['profession'] === '' ) {
            this.hasError = false;
        } else {
            this.hasError = true;
            axios.post('/vueitems', input).then(function (response) {
                _this.newItem = { 'name': '', 'age': '', 'profession': '' };
                _this.getVueItems();
            });
            this.hasDeleted = true;
        }
    },
    editItem: function(){
        var i_val_۱ = document.getElementById('e_id');
        var n_val_۱ = document.getElementById('e_name');
        var a_val_۱ = document.getElementById('e_age');
        var p_val_۱ = document.getElementById('e_profession');

        axios.post('/edititems/' + i_val_۱.value, {val_۱: n_val_۱.value, val_۲: a_val_۱.value,val_۳: p_val_۱.value })
            .then(response => {
                this.getVueItems();
                this.showModal=false
            });
        this.hasDeleted = true;

    },
    deleteItem: function deleteItem(item) {
        var _this = this;
        axios.post('/vueitems/' + item.id).then(function (response) {
            _this.getVueItems();
            _this.hasError = true,
                _this.hasDeleted = false

        });
    }
}

});
"

ثبت پرسش جدید

پاسخ‌ها

5
حسام موسوی
حسام موسوی
@hesammousavi

تخصص: طراح و برنامه نویس

بهترین پاسخ

سلام برای اپلود تصویر باید از FormData در جاوااسکریپت استفاده کنید و Content-type هم نباید رویه json باشه

ahph
ahph
@ahph1528

لطفا راهنمایی بفرمایید

داود خانی
داود خانی
@davoodkhany

تخصص: برنامه نویس لاراول و متخصص سئو

سلام حقیقتش من تا حالا عکسی با vue آپلود تکردم ولی پیشنهاد آدرس عکس رو بفرست سمت کنترلر لاراول همون ور ذخیرش کن اگه تا حالا عکسی تو لاراول آپلود نکردی بگید کدشو براتون بفرستم ؟؟؟

شاید پاسخ شما همین‌جا باشد

milad
milad
@miladtest70

چرا از dropzone استفاده نمیکنی؟

امیر باقری
امیر باقری
@lordwebiran

تخصص: مدیر عامل

سلام حسام جان من یک روند ذخیره سازی عکس دارم ولی درست عمل نمیکنه
کد هارو ارسال میکنم امکانش یود ممنون میشم حمایتم بدی

برای ارسال پاسخ لازم است وارد شده یا ثبت‌نام کنید

ورود یا ثبت‌نام