Disk [public] does not have a configured driver. in laravel image upload

Stefan Bogdanescu

Founder & Senior Architect · 2026-06-29

Laravel Company

Solving the Mystery: "Disk [public] does not have a configured driver" in Laravel Image Uploads

As developers, we often encounter frustrating runtime errors that seem completely arbitrary. One such common issue in Laravel applications dealing with file uploads—especially when using the Filesystem abstraction layer—is the cryptic error: Disk [public] does not have a configured driver.

This post will dive deep into why this error occurs, even when your configuration in config/filesystems.php looks perfectly fine, and provide a definitive guide on how to fix it, ensuring your file uploads work seamlessly.

Understanding the Filesystem Abstraction Layer

Laravel’s filesystem component is incredibly powerful, abstracting away the complexities of various storage solutions (local disk, S3, FTP, etc.). It uses "disks" to manage these different storage types. The error you are seeing indicates that when your application attempts to use a specific disk named public (likely via storePublicly()), Laravel cannot find the necessary driver to handle the physical storage of those files.

In essence, the configuration file tells Laravel what disks exist, but the driver is the actual mechanism that knows how to interact with that path on your operating system.

Why the Error Appears Despite Correct Configuration

You correctly pointed out that your config/filesystems.php looks correct:

'public' => [
    'driver' => 'local', // This dictates the driver used
    'root' => storage_path('app/public'),
    'url' => env('APP_URL').'/storage',
    'visibility' => 'public',
],

If this configuration is present, the error usually stems from one of three main issues:

  1. Missing Directory Setup: The physical directory (storage/app/public) does not exist or Laravel cannot write to it (permission issues).
  2. Driver Initialization Failure: In some complex setups, if a custom driver is involved, that driver might not be properly registered or loaded in the service container.
  3. Caching Issues: Sometimes, stale configuration caches can cause Laravel to misinterpret the setup.

Since you are using the local driver, the most common culprit is related to file system permissions or the initial setup of the storage directory itself, rather than a flaw in the configuration definition itself.

The Solution: Ensuring Proper Local Disk Setup

To resolve this, we need to ensure that the local disk driver is fully operational and accessible by the application. We must explicitly check the physical structure Laravel expects.

Step 1: Verify and Create Storage Directories

Before attempting any uploads, you must manually ensure the directories defined in your configuration exist and are writable by the web server process (like Apache or Nginx).

Run these commands in your project root to set up the necessary public storage folders:

# Ensure the main storage directory exists
mkdir -p storage/app/public

# Set appropriate permissions for web access (adjust based on your OS)
chmod -R 775 storage/app/public

Step 2: Re-evaluate Your Upload Logic

While the error points to configuration, let's ensure your upload logic is robust. The method storePublicly() is designed to handle the creation of public links automatically, but it relies entirely on the underlying disk being functional.

If you are still encountering issues after fixing permissions, consider using a dedicated package or ensuring that any custom file system setup adheres strictly to the principles outlined by the Laravel documentation. For robust file handling, always refer back to best practices provided by the core framework, such as those detailed at laravelcompany.com.

Here is a slightly refined example of how you might handle storage operations, focusing on clarity:

use Illuminate\Http\Request;
use App\Models\Product; // Assuming your model name

public function upload(Request $request, Product $product)
{
    $image = $request->file('file');

    // Store the file using the configured disk ('public')
    // The 'storePublicly' method handles saving and creating the public URL path.
    $dbPath = $image->storePublicly('uploads/catalog/' . $product->id, 'public');

    if ($product->images === null || $product->images->count() === 0) {
        $imageModel = $product->images()->create([
            'path' => $dbPath, // Store the path returned by storePublicly
            'is_main_image' => 1,
        ]);
    } else {
        $imageModel = $product->images()->create(['path' => $dbPath]);
    }

    return response()->json(['image' => $imageModel]);
}

Conclusion

The error "Disk [public] does not have a configured driver" is rarely about a simple typo in filesystems.php. It is almost always a symptom of a mismatch between the configuration definition and the actual physical environment (permissions, directory existence). By systematically checking file system permissions and ensuring that the underlying local disk structure is correctly established, you resolve this issue. Always remember that understanding how Laravel manages its storage abstractions is key to building scalable and reliable applications, as demonstrated by the principles outlined at laravelcompany.com.