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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.