Home > Back-end >  Image keeps changing filetype on upload
Image keeps changing filetype on upload

Time:03-23

When trying to upload an image, the mimetype keeps changing from imaage/jpg to application/octet-stream, I have no clue why because I could upload the same image 5 times and each time could give a different mimetype, is there a way to force laravel or vue.js to make application/octet-stream into an image type? here is my HTML

<input type="file" id="banner" name="filename">

Here is my vue.js post request using inertia.js

this.$inertia.post(route('user.edit', this.user.id), object,{
            onSuccess: () => {
                this.sweetAlertSuccess(attribute); // fire success message
                axios.get('/user/'   this.user.id).then(resp => {
                    resp.data.media.forEach(el => {
                        if(el.collection_name === 'banner'){
                            this.banner = el.original_url;
                        }
                        if(el.collection_name === 'avatar'){
                            this.avatar = el.original_url;
                        }
                    });
                });
            }

CodePudding user response:

This happens because your server is not accepting the weight of the images and by default it changes the mime type, modify the following variables in the php.ini

(to locate this file check the phpinfo(); function)

<?php
    phpinfo();
?>
upload_max_filesize = 60M
post_max_size = 60M

The value by default is in 2M, set this value according to yours need, after modifying php.ini file(s), you need to restart your HTTP server to use the new configuration.

May be need any of this commands:

service apache2 restart
service httpd restart
service php-fpm restart
  • Related