Home >Backend Development >PHP Tutorial >PHP accesses files on machines within the LAN

PHP accesses files on machines within the LAN

WBOY
WBOYOriginal
2016-08-08 09:20:521692browse

今天有个需求,需要访问局域网内机器的文件,之前没做过,折腾了一天,

<code><span>$location</span> = <span>"\\\\192.168.1.111\\d$"</span>;<span>//184机器上面的d盘</span><span>$user</span> = <span>"administrator"</span>;<span>//用户名</span><span>$pass</span> = <span>"xxxx"</span>;<span>//密码</span><span>$letter</span> = <span>"z"</span>;<span>//把远程机器上的地址映射到本地的盘符</span><span>// 下面的意思是把184机器上面的d盘映射到本地的z盘</span><span>$cmd</span>=<span>"net use "</span>.<span>$letter</span>.<span>": "</span>.<span>$location</span>.<span>" \""</span>.<span>$pass</span>.<span>"\" /user:\""</span>.<span>$user</span>.<span>"\""</span>;
<span>system</span>(<span>$cmd</span>);
<span>//下面两个是去除目录下的文件列表,无视就好</span><span>$result</span> = my_scandir(<span>'Z:'</span>);  
var_dump(<span>$result</span>);
<span>$result</span> = my_scandir1(<span>'Z:'</span>);  
var_dump(<span>$result</span>);
<span>//隐射了不用还得删除吧</span><span>$cmd</span>=<span>"net use "</span>.<span>$letter</span>.<span>": /delete"</span>;
<span>system</span>(<span>$cmd</span>);</code>

两台机器都是windows server 2008 r2 enterprise的系统

版权声明:本文为博主原创文章,未经博主允许不得转载。

以上就介绍了php访问局域网内机器的文件,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn