How to upload large file > 5MB in laravel 5

后端 未结 3 1928
逝去的感伤
逝去的感伤 2020-12-03 16:34

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

3条回答
  •  时光取名叫无心
    2020-12-03 16:43

    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

提交回复
热议问题