我试图上传音频/ mp3文件(15mb),产生以下错误"该文件必须是类型为:mpga"的文件。当我上传其他文档音频/ mp3(7mb)时,不会出现错误。
在验证中:
$validator = Validator::make($request->all(), [
'name' => 'required|string|max:255',
'file' => 'required|mimes:mpga'
]);
php.ini中的
upload_max_filesize=25M
max_file_uploads=25
post_max_size=25M
有关两个文件的更多信息:
第一个文档(错误)
Illuminate\Http\UploadedFile {#414
-test: false
-originalName: "bondad (1).mp3"
-mimeType: "audio/mp3"
-size: 4734618
-error: 0
#hashName: null
path: "C:\xampp\tmp"
filename: "php208F.tmp"
basename: "php208F.tmp"
pathname: "C:\xampp\tmp\php208F.tmp"
extension: "tmp"
realPath: "C:\xampp\tmp\php208F.tmp"
aTime: 2017-12-19 13:53:30
mTime: 2017-12-19 13:53:30
cTime: 2017-12-19 13:53:30
inode: 0
size: 4734618
perms: 0100666
owner: 0
group: 0
type: "file"
writable: true
readable: true
executable: false
file: true
dir: false
link: false
linkTarget: "C:\xampp\tmp\php208F.tmp"
}
第二份文件(好)
-test: false
-originalName: "10 minutos de meditacion respirando.mp3"
-mimeType: "audio/mp3"
-size: 14418620
-error: 0
#hashName: null
path: "C:\xampp\tmp"
filename: "phpBFBB.tmp"
basename: "phpBFBB.tmp"
pathname: "C:\xampp\tmp\phpBFBB.tmp"
extension: "tmp"
realPath: "C:\xampp\tmp\phpBFBB.tmp"
aTime: 2017-12-19 13:55:16
mTime: 2017-12-19 13:55:16
cTime: 2017-12-19 13:55:16
inode: 0
size: 14418620
perms: 0100666
owner: 0
group: 0
type: "file"
writable: true
readable: true
executable: false
file: true
dir: false
link: false
linkTarget: "C:\xampp\tmp\phpBFBB.tmp"
答案 0 :(得分:1)
这可能取决于mp3文件中的确切内容。我认为更好的解决方案可能是使用:
mimes:mp3
而不是:
mimes:mpga
或者你可以像这样组合多个哑剧:
mimes:mpga,mp3
答案 1 :(得分:0)
您可以使用mimetypes验证规则来匹配mime类型,这是一个示例:
$validator = Validator::make($request->all(), [
'name' => 'required|string|max:255',
'file' => 'required|mimetypes:audio/mp3,application/octet-stream'
]);
希望这个肝脏