'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



Solution 1:[1]

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

Solution 2:[2]

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.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Obsidian
Solution 2 Lani Asep Sutisna