开发者

PHP file copy to another server; Access filesystem on other server

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开发者_StackOverflow社区 our server did not possess.


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


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.


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


You might also want to look at the FTP functions.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜