Have you run php artisan storage:link to create a symbolic link to your public storage directory?
Aug 18, 2021
3
Level 1
Image retrieving
Hi developers, I can upload the files into storage folder without any issue in lumen but when I try to retrieve it I am getting an error message saying The requested resource /storage/profile_images/1629284722_1.jpg was not found on this server.
profile = $request->file('profile'); //Get file name with extension $filen_name_with_ext = $profile->getClientOriginalName();
// Get only file name
$file_name = pathinfo($filen_name_with_ext, PATHINFO_FILENAME);
// Get only the extension
$file_ext = $profile->getClientOriginalExtension();
$file_name_to_store = time().'_'.$request->staff_id.'.'.$file_ext;
$file_directory = storage_path().'/'.'profile_images';
if (!file_exists($file_directory)) {
// directory not exists
if (File::makeDirectory($file_directory, 0777, true)) {
$profile->move($file_directory .'/', $file_name_to_store);
}
else{
return response()->json(['error' => true, 'data' => 'Unable to upload profile picture!'],500);
}
}
else{
$profile->move($file_directory .'/', $file_name_to_store);
}
This is my coding. can anyone help me to retrieve the image using the url of web because I need to render the image in another project.
Level 1
Solved. I had to run this ln -s ../storage public in terminal
Please or to participate in this conversation.