laravelxamppfile-permissionssymlinklaravel-12

storage:link not creating symlink in public folder


I'm working on a Laravel 12 project using XAMPP on Windows 10.

I tried to use the following command to create the symbolic link for serving uploaded files:

php artisan storage:link

But the public/storage folder is not created. When I try to access an uploaded image like this:

http://127.0.0.1:8000/storage/flyers/qP1qViaQXlxfhrssaGVBJQFgEpogn3vx7feIuLtP.jpg

I get a 403 Forbidden error.

I have:

Here's how I uploaded the file (simplified controller code):

public function store(Request $request)
{
    $path = $request->file('image')->store('flyers', 'public');
    return $path;
}

Storage is configured like this in config/filesystems.php:

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

How can I make the storage:link command work properly on XAMPP (Windows)? Or how do I fix the 403 error when accessing uploaded files?


Solution

  • Option 1:

    Run the command prompt as an administrator, than

    php artisan storage:link 
    

    Option 2: Run the command prompt as an administrator, than

    
    mklink /D "C:\path\to\your\project\public\storage" "C:\path\to\your\project\storage\app\public"