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

abiddev's avatar

How to store files to public folder in laravel

Hi all Sorry for a basic question. I'm trying to upload files to public folder on production server (shared hosting). I've created a public drive uploads in config/filesystems.php with the following configurations 'uploads' => [ 'driver' => 'local', 'root' => public_path('uploads'), 'url' => env('APP_URL') . '/uploads', 'visibility' => 'public', ],

storage link is also established.

When file is uploaded $flag_icon->storeAs('countries', $filename, 'uploads'); it is moved to app/public/uploads folder, I want it to be moved to public_html/laravel/public folder. How can this be established?

0 likes
3 replies
Snapey's avatar

a far better solution is to make public the document root and not public_html

As well as better for the security of your site, you dont have to keep looking for workarounds.

It also means that the directory structure of your development environment matches production

martinbean's avatar

@abiddev You should not be trying to store user-uploaded files in a publicly-accessible directory. This is a security risk, as if a bad actor uploads a file with malicious code, they now have a back door into your server since you make it nicely accessible for them via a URL.

Instead, you should be uploading files to a private directory, and then generating thumbnails for display in your website.

Please or to participate in this conversation.