I can't download files from storage. Firebug console shows
FileNotFoundException in File.php line 41: The file "C:\xampp\htdocs\ct\storage/30e9734e1f06bf751da5b3289994fb3f/34.pdf" does not exist
But files are existing in C:\xampp\htdocs\ct\storage\userdata\30e9734e1f06bf751da5b3289994fb3f
folder. I think the file path I mentioned in code is not correct. Please help me to solve this issue.
filesystems.php
'root' => storage_path('userdata'),
DownloadController.php
public function show(TagambitionRequest $request)
{
$details = User::select('id', 'created_at')->findOrFail(Auth::user()->id);
$encrypt = md5($details->id.$details->created_at);
$directories = Storage::files($encrypt); // Listout Files
foreach($directories as $values)
{
$split_folder_file = explode('/', $values); //60e4dda43c442fe610bdbd4a0e5c3a12/19.pdf
$splitted_file = end($split_folder_file); //19.pdf
$explode_filename = explode('.', $splitted_file); //explode(19.pdf)
$explode_name = $explode_filename[0]; //19
$file_extension = $explode_filename[1]; //pdf
if ($file_extension == 'pdf') {
$path = storage_path().'/'.$encrypt.'/'.$splitted_file;
return response()->download($path, $splitted_file, ['Content-Type' => 'application/pdf']);
}
}
}