1
votes

How to get image url with mimeType in laravel 8 from Storage sub folder.

My Folder look like this :

enter image description here

I want to access this image marked in red, So I did these steps:

Step 1 : Create Link using ** php artisan storage:link **

Then In my Controller :

$exists =  Storage::disk('public')->get('/app/media/HRTKD1607258351/HRTKD1607258351');
    if($exists) {
        return "File Found";
    }else{
        return "File Not Found";
    }

But I am getting File Not Found Error.

Can somebody help me?

Thanks in advance.

2
Storage::disk('public')->get('/app/media/HRTKD1607258351/HRTKD1607258351.jpg'); here .jpg was missingKamlesh Paul
But I don't know there is .jpg or not, Then How I will access this. I uploaded many format like .jpg, .png then ?Pooja
Using this Storage::disk('public')->get('/app/media/HRTKD1607258351/HRTKD1607258351.jpg'); also giving me file not found exceptionPooja
then you may need only match the file name without extension to verify onlyKamlesh Paul
I already did but it is giving FileNotFound Exception @KamleshPaulPooja

2 Answers

1
votes

Try this:

Storage::disk('media')->url('HRTKD1607258351/HRTKD1607258351.jpg');

0
votes

Specify the port that the application is using.

e.g set app url in .env to APP_URL=http://localhost:8000