Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

amandeep.894's avatar

Uploading a file on laravel and making it publicly accessible.

I'm trying to upload a file using the following;

$path = $request->file('logo_upload')->store('institute_logos');

Now, any file I upload gets stored to /path/to/my/laravel/project/storage/app/institute_logos and not to the /path/to/my/laravel/project/storage/app/public/institute_logos/ directory (using which I can make the file accessible publicly from the web).

Where am I going wrong?

0 likes
5 replies
Rebwar's avatar

create a symbolic link from public/storage to storage/app/public to make your files accessible from the web.

try to use storage:link command, to create symbolic link:

php artisan storage:link

once a file has been stored and the symbolic link has been created, you can create a URL to the files using the asset helper:

echo asset('storage/file.txt');
amandeep.894's avatar

Thanks for the reply.

I have already done that and i can indeed access the files that are present in the public directory, but the thing is when i upload the files, then do not get uploaded in the public directory (in the app directory instead).

Rebwar's avatar

to make sure that your symbolic is correct, try:

ln -s /laravel/path/storage/app/public /laravel/path/public/storage
kfirba's avatar
kfirba
Best Answer
Level 50

@Rebwar that's not his issue...

@amandeep.894 hey.

The way I currently solve it is to manually specify the public directory while saving my files:

$path = request('my_file')->store('public/institute_logos');
$path = str_replace('public/', '/storage/', $path);

// now wherever you need to display the image, you can just immediately use the path:

<img src="{{ $model->photo }}">

There might be a more elegant solution tho

Hope that helps you.

1 like
mcarazzo's avatar

If you check the https://laravel.com/docs/5.4/filesystem documentation, you will notice that you can set several disk on your configuration, publics or not. Then you can upload a file using the storeAs() method and there you can indicate what disk you want to use.

Please or to participate in this conversation.