Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

How to access the network drive???

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

How to access the network drive???

Postby bobo » Mon Jul 21, 2003 1:13 am

It appears that opendir() can't open directories over a network or on mapped network drives in Windows 2000.

$open = opendir("k:\\");
k: is the mapped network drive that I want to access.

Can anyone help?? :(
bobo
New php-forum User
New php-forum User
 
Posts: 12
Joined: Mon Jul 21, 2003 1:09 am

Postby swirlee » Mon Jul 21, 2003 5:49 am

It would appear that this is a permissions problem. The very first comment on the opendir() page in the documentation provides some insight. To quote:

Matt Grimm wrote:Thought I could help clarify something with accessing network shares on a Windows network (2000 in this case), running PHP 4.3.2 under Apache 2.0.44.

However you are logged into the Windows box, your Apache service must be running under an account which has access to the share. The easiest (and probably least safe) way for me was to change the user for the Apache service to the computer administrator (do this in the service properties, under the "Log On" tab). After restarting Apache, I could access mapped drives by their assigned drive letter ("z:") or regular shares by their UNC path ("\\\\shareDrive\\shareDir").
User avatar
swirlee
Moderator
Moderator
 
Posts: 2272
Joined: Sat Jul 05, 2003 1:18 pm
Location: A bunk in the back

clarify the problem!!

Postby bobo » Tue Jul 22, 2003 9:10 pm

swirlee...
i think you misunderstood my problem....
Let me show another example:

I want to upload a file using ftp:

$destination_file = test.txt;

$source_file = "c:\test.txt";
this one works OK!!
$source_file ="p:\test.txt";
DOESN'T WORK!! where p:\ is a network drive.

$upload = ftp_put($conn_id, $destination_file, $source_file, FTP_ASCII);
bobo
New php-forum User
New php-forum User
 
Posts: 12
Joined: Mon Jul 21, 2003 1:09 am

Re: clarify the problem!!

Postby swirlee » Wed Jul 23, 2003 6:49 am

bobo wrote:swirlee...
i think you misunderstood my problem....
Let me show another example:


I didn't misunderstand your problem and I still think that this is a permission problem. Your problem is that PHP can't connect to and retrieve a file from a network drive, correct? Well, in order for PHP to be able to connect to a network drive, it must be running under a user account which has access to that network drive. Do you know what user account your server process is running under? Have you confirmed that this user account has access to the network drive in question?
User avatar
swirlee
Moderator
Moderator
 
Posts: 2272
Joined: Sat Jul 05, 2003 1:18 pm
Location: A bunk in the back

Postby bobo » Fri Jul 25, 2003 5:41 am

:roll:
p:\ is the window 2000 server
I'm sure that I have the permission to read from the server. I'm so sure because I can copy the file from p:\ to my local working directory c:\.....

but I really don't understand why I cannot get the file in p:\ directly from there and upload the file to the remote site!!!

$source = p:\test.txt;
$upload = ftp_put(conn, destination, source, FTP BINARY);
bobo
New php-forum User
New php-forum User
 
Posts: 12
Joined: Mon Jul 21, 2003 1:09 am

Postby swirlee » Fri Jul 25, 2003 5:48 am

bobo wrote:I'm sure that I have the permission to read from the server. I'm so sure because I can copy the file from p:\ to my local working directory c:\.....


I didn't ask whether or not you have permission to access the file. I asked whether PHP, which is called by the web server which runs as a service, likely under a different user account than the one you log in with, has access to the file. Whether or not you can manipulate a file through your Windows account is completely irrelevant, as PHP is almost certainly operating from a different account.
User avatar
swirlee
Moderator
Moderator
 
Posts: 2272
Joined: Sat Jul 05, 2003 1:18 pm
Location: A bunk in the back

Postby bobo » Mon Jul 28, 2003 7:30 pm

so.. what I have to do in order to access the file from p:\??? :cry:
can you explain the procedure?? Thanks..
bobo
New php-forum User
New php-forum User
 
Posts: 12
Joined: Mon Jul 21, 2003 1:09 am

Postby Redcircle » Wed Jul 30, 2003 12:15 pm

you might try using the UNC of the drive \\servername\sharename not sure if it will work.. haven't tested it.
User avatar
Redcircle
Moderator
Moderator
 
Posts: 830
Joined: Tue Jan 21, 2003 10:42 pm
Location: Michigan USA

Postby swirlee » Wed Jul 30, 2003 12:52 pm

He'll almost certainly run into the same permissions problem. The quote from the comment on the opendir() page in the documentation that I posted with my first message explains how to fix this.
User avatar
swirlee
Moderator
Moderator
 
Posts: 2272
Joined: Sat Jul 05, 2003 1:18 pm
Location: A bunk in the back


Return to PHP coding => General

Who is online

Users browsing this forum: Google Feedfetcher and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.