简体   繁体   中英

Upload File in laravel very slow

I am working on uploading video file in laravel but the problem that it takes much time as it could reached to 2-3 minutes

This is the snippet of code

if($courseclass->video !="")
                    {
                        $content = @file_get_contents(public_path().'/video/class/'.$courseclass->video);

                        if ($content) {
                            unlink(public_path().'/video/class/'.$courseclass->video);
                        }
                    }

Do anyone has an idea about this, Thanks in advance

You can use php's file_exists() method instead of file_get_contents()

You are using php main function which is file_get_contents this is probably the main cause. My suggestion is to use the default file upload feature from Laravel file system storage

This slow upload problem happened at file_get_contents very slow because it uses the basic function file_get_contents. Hopefully useful, thank you.

Did you try Spatie? https://spatie.be/docs/laravel-medialibrary/v9/introduction It is a laravel media library.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM