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

angelorigo's avatar

Where Laravel store uploaded files

Hi, i need to discover where Laravel store uploaded files.

I have this variable : self::$app['config']->get('filesystems.default')

And : $path = Storage::putFileAs(MapFiles::UPLOAD_FOLDER_DEFAULT, $request->file, $fileName);

How can i get the path of the uploaded files ?

0 likes
3 replies
LaryAI's avatar
Level 58

When you upload a file in Laravel using the Storage facade, the location where the file is stored depends on the filesystem disk you are using. The default disk is set in your config/filesystems.php file, and you can retrieve it with:

self::$app['config']->get('filesystems.default')

If you use:

$path = Storage::putFileAs(MapFiles::UPLOAD_FOLDER_DEFAULT, $request->file, $fileName);

The $path variable will contain the relative path to the file within the disk you are using. For example, if your default disk is local, the file will be stored in the storage/app directory by default.

How to get the full path

If you want to get the absolute path to the file, you can use:

$absolutePath = Storage::path($path);

This will give you the full path on the server.

Example

Suppose your default disk is local and you upload a file:

$path = Storage::putFileAs('uploads', $request->file('file'), 'example.txt');
  • $path will be: uploads/example.txt
  • The actual file will be stored at: storage/app/uploads/example.txt
  • To get the full path:
$absolutePath = Storage::path($path);
// Result: /full/path/to/your/project/storage/app/uploads/example.txt

If you are using the public disk, the file will be stored in storage/app/public, and you can access it via a URL if you have run php artisan storage:link.

Summary

  • Relative path: Returned by Storage::putFileAs()
  • Absolute path: Use Storage::path($path)
  • Physical location: Depends on the disk (local = storage/app, public = storage/app/public, etc.)

Let me know if you need more details on a specific disk or setup!

Snapey's avatar

A few observations.

  1. You can get the default file system with config('filesystems.default');

  2. I would suggest you don't need the above at all. Save your file to a specific disk which you have created in filesystems.php

  3. never accept the user's filename. Use a random filename, or just let Laravel assign a random filename

  4. Save the upload using the disk as $path = Storage::disk('uploads')->putFile($request->file('field_name'));

If you use a named disk, you can move where you store things by just changing the filesystem entry for that disk, and no changes are required in your code.

1 like

Please or to participate in this conversation.