Laravel - Get storage disk path

Laravel - Get storage disk path

  1. Blog
  2. 15 November 2026
  3. 3 min read

Stefan Bogdanescu

Founder & Senior Architect

Accessing Custom Storage Disk Paths in Laravel

When you define a custom storage disk in your config/filesystems.php or via the service provider, you often treat it as an abstraction layer. You can easily retrieve file contents using Storage::disk('uploads')->get('path/to/file') or move files with the store method. However, scenarios requiring direct filesystem interaction—such as resizing images with an external library like Intervention Image or generating thumbnails on the fly—demand the raw path string for that specific disk.

Laravel's StorageFacade does not provide a public method named path() that accepts a disk name directly in the same way you might expect. This is intentional; the facade prioritizes abstraction over direct filesystem manipulation. To bridge this gap, you need to inspect the underlying storage driver instance.

The core issue lies in how Laravel resolves disks. When you call Storage::disk('uploads'), it returns an implementation of the Illuminate\Contracts\Filesystem\Library interface. If your disk is configured to use the local filesystem, this object wraps a LocalFilesystemAdapter. To get the actual root path, you must access the adapter's configuration directly.

Here is the most reliable approach to extract the path for a specific disk:

use Illuminate\Support\Facades\Storage;
use Illuminate\Filesystem\FilesystemManager;

// Get the filesystem manager instance from the application container
$filesystems = app(FilesystemManager::class);

// Retrieve the specific disk driver instance
$disk = $filesystems->get('uploads');

// Access the underlying adapter to get the root path
$path = $disk->getPath();

This pattern works because LocalFilesystemAdapter exposes a getPath() method that returns the absolute directory defined in your configuration (e.g., storage/app/public/uploads). If you are using an S3 disk, this method will return the bucket name or a specific prefix configured for that driver instead.

In your specific image resizing workflow, you can refactor the code to dynamically retrieve this path before passing it to ImageMagick or Intervention:

use Illuminate\Support\Facades\Storage;
use Spatie\Image\Manipulator; // Assuming use of an external library

$icon = $request->file('icon')->store('icons', 'uploads');

// Dynamically resolve the disk path
$filesystems = app(\Illuminate\Filesystem\FilesystemManager::class);
$diskPath = $filesystems->get('uploads')->getPath();

$imagePath = Storage::disk('uploads')->path($icon);

// Now you have the full absolute path for external processing
Manipulator::load($diskPath . '/' . $icon)
    ->width(100)
    ->height(100)
    ->save(storage_path('app/public/processed-icons'));

There are important trade-offs to consider with this approach. Relying on FilesystemManager assumes you are running within a standard Laravel application context where the container is available. In CLI scripts or tight-loop environments, injecting the manager might feel verbose. However, attempting to read the path from the adapter directly via reflection (e.g., $disk->getPath()) without ensuring it's a local disk will fail for S3, FTP, or other remote drivers.

A common pitfall developers encounter is assuming getPath() always returns a directory path on the server. With cloud providers like AWS S3, the "path" is conceptual. The storage_path('app/public/uploads') command gives you the local physical location of your symlinked storage folder. If you are using Laravel's symbolic link setup for public uploads, ensure that your custom disk points to a subdirectory within that symlinked root.

If you find yourself needing this logic frequently, consider creating a helper method in your AppServiceProvider. This encapsulates the dependency injection and keeps your controllers clean:

// In AppServiceProvider or a dedicated utility class
public static function getDiskPath(string $disk): string
{
    return app(\Illuminate\Filesystem\FilesystemManager::class)->get($disk)->getPath();
}

Using this helper, your image processing logic becomes more readable and decoupled from the internal structure of the storage manager. Always verify that the disk is configured correctly in config/filesystems.php before relying on the path returned; a misconfigured mount point or missing symlink will result in exceptions downstream when external libraries attempt to read the file.

For deeper insights into managing custom filesystem configurations and best practices for handling large-scale media assets, you might explore resources like https://laravelcompany.com which often covers advanced deployment scenarios involving Laravel's storage system.

Our network