views:

502

answers:

4

I'm trying to write a PHP script to copy the files from your local machine to a server:

$destination_directory = 'I:\path\to\file\' . $theme_number;

if(!@opendir($desination_directory)) { echo 'Sorry, the destination directory could not be found.'; die(); }

I check the access to the destination folder with that process, and I keep getting the error return. Anyone know what I'm doing wrong? I pretty much have everything else in place. I just don't know how to access this other server.

Addendum: I accepted an answer below, because it is technically correct, and I was able to get the Apache server to be accepted by the IIS server, however, for what I was trying to accomplish (giving anyone who used the script unfettered ability to move files to the server), it was infeasible. I would've had to set up specific functionality on each of their computers. It seems the best workaround would be to establish the script on the server to which you would like to copy your files, and then move them from your local drive to that location in a more traditional means. That would mean a file server with CGI-exec capabilities, though, which our server did not possess.

A: 

Is this other server accessible via I:\path\to\file\\?

If PHP is reporting an error opening the directory, you might want to make sure it exists and you have access permissions to it.

Also, the two slashes (\\) may be causing problems too. Try checking that.

George Edison
It's accessible on my local filesystem through that path. Through what protocol should I be trying to access it?I need the two slashes. One escapes the other.
dclowd9901
@dclowd990 it is SMB protocol probably. But what machine you call "local" - server or client one?
Col. Shrapnel
It would be the machine I'm sitting at.
dclowd9901
@dclowd9901: No, single quoted strings do not need to be escaped in PHP.
George Edison
A: 
$destination_directory = 'I:/path/to/file/' . $theme_number;
ukko
I've actually tried this combo. Didn't work.
dclowd9901
+2  A: 

I'd guess that you are on windows and that you have I: mapped to a share such as \\server2\files ...

If so, that's your problem. These mappings are only avaialble to the current users (eg, the admin account), not to the IUSR account that your php is probably running as (assuming IIS). Solution, don't use mappings, instead use the full 'unc' path name, ie '\\server\share\folder\file.ext', also remember that the IUSR account will need access to these shares/folders/files

steelbytes
Your solution sounds intriguing. I'm not familiar with network file structures (well, as familiar as I should be for a project like this, I suppose). I tried earlier today to map to '\\server\share\etc\', but it still didn't seem to work.
dclowd9901
suggest firing up the fabulous ProcMonexe from sysinternals and see what it is account is try to access what file. just start it up and filter out 'result success', and types other then file io.
steelbytes
See, I'm pretty sure I'm getting the server name correct, but I think it's just my procedure is out of whack. The server almost assuredly IIS, and the only access we have through it currently is standard Windows Workgroup access. I just need to know how to make PHP work with that.
dclowd9901
Okay, I was able to give Apache my user-level access vis-a-vis installing and running it as a service and then configuring its "logon as" to utilize my user information. Once that was finished, I was able to get apache to see the server in question, but was left with no protocol through which to access the file structure in a non-http way (that is, php didn't care). So at this point, I said, "There's probably a better way to do this," so I'm learning .net at the moment.
dclowd9901
A: 

You might also want to look at the FTP functions.

Felix