Jump to content

Copy file over a mapped network drive using PHP


hannibal

Recommended Posts

I have tried to upload a file to an internal (different) network server from my webserver, using the mapped drive of Z:\. However, I keep getting the following error, no matter how many variences of code I use:

 

Warning: mkdir() [function.mkdir]: No such file or directory in C:\www\domain\upload.php on line 49

CUSTOM MESSAGE:Cannot make DIR: Z:\ - ERROR CREATING:Z:\

 

However, if I change my file to C:\, the upload works like a charm. I have checked and the web user (system) has access to the mapped Z:\ drive which auto reconnects at login. I am using latest PHP and Apache.

 

I have even tried using the IP address of the other server, but this just creates a folder in my www\domain folder, called 192.168.0.5\fileToBeUploaded.

 

Many thanks,

 

Jay

mapped drives are user specific.  The webserver, and consequentially php, run under a different username (IUSER_servername).  Therefor, the mapped drives that you have, are not available to php.

 

Use something like the following to access that server:

 

copy('./source_file.txt', '\\255.255.255.255\c$\uploaded_files\source_file.txt');

 

Note the two backslashes before the server IP (or server name).  I used c$, but you can use any shared folder.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.