[在我的Laravel项目中,我需要上传mp3文件,但是Laravel使用mpga
作为mime类型来验证mp3
文件类型,我发现在此answer中。
$results = Validator::make($request->all(), [
"song" => "required|file|mimes:mpga|max:8192",
]);
我很好,但是我的问题是文件以mpga
扩展名存储,我从此answer知道此奇怪操作的原因。
但是我想存储扩展名为mp3
的文件。
没有看到您的代码,我最好的建议是使用putFileAs()类中的Storage
方法。
[此方法允许您在存储文件时指定文件名:
use Illuminate\Http\File;
use Illuminate\Support\Facades\Storage;
// Manually specify a file name:
Storage::putFileAs('folder', new File('/path/to/uploaded-music.mp3'), 'stored-song-name.mp3');
请参见Laravel文档:https://laravel.com/docs/5.8/filesystem#storing-files