storage_path to ignore root directory user (laravel 5.6)
My laravel app is uploaded on a shared hosting in a sub-domain the problem is that my images are not being accessed in view while it's working in local without any error.
this is how i am accessing my images from storage path.
Route::get('photoIcon/{file_name}', function ($filename) {
$path = storage_path('app') . '\public\photoIcon\' . $filename;
$image = \File::get($path);
$mime = \File::mimeType($path);
return \Response::make($image, 200)->header('Content-Type', $mime);
})->name('photoIcon');
my larave app files are saved in my sub domain:
names.mydomain.com
the image route , the $path variable loads images with accessing this link .
/home/myHostingUserName/names.mydomain.com/local/storage/app\public\photoIcon/image.png
problem is with prefix
/home/myHostingUserName
and it arias an error of
File does not exist at path /home/myHostingUserName/names.mydomain.com/local/storage/app\public\photoIcon/image.png
it looks to find image inside /home/myHostingUserName where that is my hosting user name
how can i set up to search image only inside sub-domain and should remove my hosting user name from root path it must be something like this:
names.mydomain.com/local/storage/app\public\photoIcon/image.png
while i past the image link without the prefix /home/myHostingUserName in browser search bar. it loads the image without any error.
how can i remvoe the prefix from image path?
please thank you .
$path = storage_path('app') . '/public/photoIcon/' . $filename;
Please or to participate in this conversation.