图像在上传时不断改变文件类型
当尝试上传图像时,mimetype 不断从 imaage/jpg 更改为 application/octet-stream,我不知道为什么,因为我可以上传相同的图像 5 次,每次都会给出不同的 mimetype,有没有办法强制 laravel 或 vue.js 将 application/octet-stream 转换为图像类型? 这是我的 HTML
<input type="file" id="banner" name="filename">
这是我使用惯性.js 的 vue.js post 请求
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;
}
});
});
}
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;
}
});
});
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
发生这种情况是因为您的服务器不接受图像的重量,并且默认情况下它会更改 mime 类型,请修改
php.ini
中的以下变量(要找到此文件,请检查
phpinfo( );
函数)默认值是2M,根据自己的需要设置这个值,修改
php.ini
文件后,需要重启HTTP服务器才能使用新配置。可能需要以下任何命令:
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)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: