Hi everyone,
I'm trying to configure Laravel to store uploaded files on a network drive, but I'm running into issues. I hope someone here can help!
My Setup
Laravel version: 10.x
OS: Windows Server 2019
Web server: IIS
Network share: \CORP-SERVER\SharedDocs\laravel_uploads
Mapped drive: X:\ (mapped to the above network share)
What I Want
I want Laravel to save uploaded files to a folder on the network drive, for example:
X:\project_files\invoices\
What I Tried
I mapped the network share to X: using:
text
net use X: \CORP-SERVER\SharedDocs\laravel_uploads /persistent:yes
In config/filesystems.php:
php
'disks' => [
'local' => [
'driver' => 'local',
'root' => 'X:\project_files\invoices',
],
],
My upload code uses:
php
$path = $request->file('document')->storeAs('pdf', 'invoice_123.pdf', 'local');
The Problem
When I try to upload a file, I get this error:
Impossible to create the root directory "X:\project_files\invoices".
Also, when I try to open X: in Windows Explorer, I get a network error saying Windows can't access the drive.
What I've Checked
The folder X:\project_files\invoices exists and is writable from my user account.
The network share is accessible from my user session.
The web server runs under the default IIS user.
My Questions
How can I make Laravel (running under IIS) access and write to a network drive?
Is there a better way to configure the disk in filesystems.php for a network share?
Do I need to use UNC paths instead of mapped drives?
What permissions or user context should I set for the web server?
Any advice or best practices would be greatly appreciated!