嘗試上傳影像時,mimetype 不斷從 image/jpg 變為 application/octet-stream,我不知道為什么,因為我可以上傳相同的影像 5 次,每次都可以給出不同的 mimetype,有沒有辦法強制 laravel 或 vue.js 將 application/octet-stream 轉換為影像型別?這是我的 HTML
<input type="file" id="banner" name="filename">
這是我使用慣性.js 的 vue.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;
}
});
});
}
uj5u.com熱心網友回復:
發生這種情況是因為您的服務器不接受影像的權重,并且默認情況下它會更改 mime 型別,請修改以下變數php.ini
(要找到這個檔案檢查phpinfo();功能)
<?php
phpinfo();
?>
upload_max_filesize = 60M
post_max_size = 60M
默認值是2M,根據你的需要設定這個值,修改php.ini檔案后,你需要重啟你的HTTP服務器才能使用新的配置。
可能需要以下任何命令:
service apache2 restart
service httpd restart
service php-fpm restart
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/448431.html
