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

forum-user's avatar

File storage outside laravel app folder

Hello guys! I am rebuilding an audio hosting web site. And the way our storage set up is we store audio files on the same server where the site is, we dont use s3 or any other cloud hosting, we self host our files. When someone uploads a new file it is being uploaded to folder inside my app. So the folder structure is like this: /var/www/my-site - my website. /var/www/my-site/audio-storage - folder where new files are uploaded. But in fact this folder /var/www/my-site/audio-storage is not a folder it is a symlink to this path /hdd_raid18/stoarge which is a folder on a different disk.

That is how the storage was set up in our legacy app, we started to rebuild our website using Laravel, and I am trying to figure out a good way to store files. So it seems like my options are: a) create a new laravel storage disk in config/filesystems.php and just set its root to /hdd_raid18/storage b) create new disk inside laravel storage folder but symlink it to /hdd_raid18/storage

What do you think of these options? Or maybe you can suggest something better? Do you think creating a laravel disks outside of laravel folder is a bad idea?

Thank you!

P.S I know self hosting is not preferrred these days but my boss doesnt consider storing files in a cloud.

0 likes
2 replies
Snapey's avatar
Snapey
Best Answer
Level 122

I don't think it matters as long as you pull the path into the filesystems config file from an environment variable so that there's nothing hard coded into your app other than the disk name you chose.

You haven't mentioned if the files need to be externally served by your webserver, but that would also be a consideration.

1 like
forum-user's avatar

@Snapey Thank you for your reply.

We will be serving those files but won't be using direct links to files. Instead we manually serve downloads via controller which uses X-Accel-Redirect header to serve files because we need to save audio download stats.

return response(null)
            ->header('Content-Disposition', 'attachment; filename="' . 'filename.mp3' . '"')
            ->header('X-Accel-Redirect',  $audio->getPath())
            ->header('Content-type', 'audio/mpeg');

Please or to participate in this conversation.