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
CodePudding user response:
You can use php's file_exists() method instead of file_get_contents()
CodePudding user response:
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.
CodePudding user response:
Did you try Spatie? https://spatie.be/docs/laravel-medialibrary/v9/introduction It is a laravel media library.