#### view base64 _encoded image laravel

$file =$request->file('photo');
if (!empty($file)) {$fileName = $file->getClientOriginalName();$folder = uniqid() . '-' . now()->timestamp;
$filePath = Storage::disk('fileUploadToPublic')->putFileAs("contentFiles/{$folder}", $file,$fileName);
$dataToInsert['photo'] =$filePath;

}


I used to store the uploaded image inside the public folder before with the above code , so i could view the image with its filepath. But now, i would like to know, whether i can avoid storing file as such by using the base64_encode().The below code shows the error BadMethodCallException: Method IlluminateHttpUploadedFile::pat‌​h does not exist. i think am getting this error becoz am not uploading the image anywhere. Some experts pls give me some suggestions..

$file =$request->file('photo');
if (!empty($file)) {$dataToInsert['photo'] =base64_encode(file_get_contents(\$file->pat‌​h()));
}


Source: Laravel