Harshith J Poojary
Harshith J Poojary

Reputation: 331

Laravel file Uploading returning null when size is large

I am trying to upload videos using laravel, filepond and s3 bucket. When file size is greater than 5Mb aws is not returning anything and even the file is not getting uploaded. But when the file size is less than 5Mb it's getting uploaded and I am able to get the s3 file path.

public function upload_video(Request $request){
    if ($request->hasFile('link')) {
        $video_link = Storage::disk('s3')->put('videos', $request->file('link'));

        return $video_link;
    }
}

Upvotes: 0

Views: 1360

Answers (2)

Jijo Alexander
Jijo Alexander

Reputation: 1290

Ensure PHP.INI settings were allowing uploads high enough. PHP.INI only allows 2M by default, so increased this limit to 20M. And Amazon S3 doesn’t like files over 5 MB uploading in one go, instead, you need to stream it through.

please use the given reference link to solve this issue by using streaming from server to S3.

https://www.webdesign101.net/laravel-s3-uploads-failing-when-uploading-large-files-in-laravel-5-8/

Upvotes: 1

Mansjoer
Mansjoer

Reputation: 184

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+'));

Upvotes: 0

Related Questions