gpt4 book ai didi

laravel - 上传文件大于 10MB 时出错

转载 作者:行者123 更新时间:2023-12-03 20:30:03 25 4
gpt4 key购买 nike

我想上传大于 10MB 的文件但出现错误

Spatie \ MediaLibrary \ Exceptions \ FileCannotBeAdded \ FileIsTooBig File /private/var/tmp/phpfBe4An has a size of 27.82 MB which is greater than the maximum allowed 10 MB



代码
$response = \DB::transaction(function() use($request) {
$listing = Listing::with('car')->find($request->get('listing_id'));

$fileName = rand(1111, 9999) . '_' . time() . '.' . $request->file('video')->getClientOriginalExtension();
$media = $listing->addMedia($request->file('video'))->usingFileName($fileName)->toMediaCollection('listing_videos');

return response()->json([
'success' => 1,
]);
});

return $response;
}

我将上传的文件保存到 amazon-s3。
提前致谢!

最佳答案

您是否调整了 max_file_size 的值?在 配置文件位于
config/medialibrary.php
如果没有设置它,例如,接受 30mb 也许?
'max_file_size' => 1024 * 1024 * 30,
如果你没有上面提到的配置文件:

通过运行发布它:
php artisan vendor:publish --provider="Spatie\MediaLibrary\MediaLibraryServiceProvider" --tag="config"
感谢@Norman Edance 指出这一点

关于laravel - 上传文件大于 10MB 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50567611/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com