1

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:

  • Confirmed the image exists in storage/app/public/flyers/

  • Run php artisan config:clear

  • Run php artisan cache:clear

  • Verified that the public/storage symlink is not present

  • Tried deleting and recreating the symlink manually, but it still doesn't work

  • Confirmed Apache is running correctly via XAMPP

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?

1
  • Well, the symlink has to exist for this to work. What exactly happens when you run the storage:link command? Maybe check the folder permissions. Make sure there is no not-working dead file that is called storage that hinders the command from creating a working symlink. Alternatively, create the link manually? Commented Jul 28 at 10:29

1 Answer 1

0

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"
Sign up to request clarification or add additional context in comments.

1 Comment

Hi @Abdullah Thanks for your reply. I tried the method you suggested and it worked well. I used the following command using git bash: ln -s /path/to/my/project/storage/app/public/ /path/to/my/project/public/storage Hopefully this method can help others.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.