如何上传大文件> 5 laravel 5 [英] How to upload large file > 5MB in laravel 5
问题描述
php.ini
post_max_size = 500M;
memory_limit = 500M;
upload_max_filesize = 500M
我已经重新启动Apache服务器,但仍然有问题。在 php.ini
或Laravel中是否有其他设置可以上传大文件?请帮忙。
编辑
$ image = $ request-> file('image');
if($ image&& $ image!=''){
$ extension = $ image-> getClientOriginalExtension();
$ imageName = $ this-> getUniqueName($ extension);
$ image-> move('gimages / profile_images /',$ imageName);
$ profile_image = $ imageName;
$ update_user_data ['image'] = $ profile_image;
$ / code>
非常感谢!
如果你想上传大文件,你应该使用流。以下是执行此操作的代码:
$ disk = Storage :: disk('s3');
$ disk-> put($ targetFile,fopen($ sourceFile,'r +'));
即使您上传了几个GB的文件,PHP也只需要几MB的RAM。 p>
来源: https://murze.be/2015/07/upload-large-files-to-s3-using-laravel-5/
<有关存储的使用和配置,请参阅Lrvl5文档:
https://laravel.com/docs /5.0/filesystem
May I know how to upload large file, more than 5Mb in Laravel 5? I am trying to upload around 10MB image file but it is not uploading, I searched a lot and updated following settings in php.ini
post_max_size = 500M;
memory_limit = 500M;
upload_max_filesize = 500M
I have restarted Apache server but still having issue. Is there any other setting in php.ini
or in Laravel to upload large files? Please help.
Edit
$image = $request->file('image');
if($image && $image != '') {
$extension = $image->getClientOriginalExtension();
$imageName = $this->getUniqueName($extension);
$image->move('gimages/profile_images/', $imageName);
$profile_image = $imageName;
$update_user_data['image'] = $profile_image;
}
Thanks much!
If you want to upload big files you should use streams. Here’s the code to do it:
$disk = Storage::disk('s3');
$disk->put($targetFile, fopen($sourceFile, 'r+'));
PHP will only require a few MB of RAM even if you upload a file of several GB.
Source: https://murze.be/2015/07/upload-large-files-to-s3-using-laravel-5/
See Lrvl5 doc for usage and config of Storage : https://laravel.com/docs/5.0/filesystem
这篇关于如何上传大文件> 5 laravel 5的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!