PHP访问局域网共享文件
各位好!我想访问局域网内另外一台计算机上的图片文件,可是在PHP里面老是找不到。在PHP里面用filesize测试图片的大小都不行!代码是:
$filename = "http://172.16.18.123/pic/2012.png";
$size = filesize($filename);
echo $size;
报的错是:Warning: filesize() [function.filesize]: stat failed for http://172.16.12.103......
我确定两台机器是在一个网段,而且共享都设置了的。我在浏览器输入上述代码中的url地址都可以的。
请教哪位处理过这种问题的大侠!不甚感激!!
回复讨论(解决方案)
$filename = "//172.16.18.123/pic/2012.png";
$filename = "//172.16.18.123/pic/2012.png";
非常感谢您!!我试了,对的!不过我发现一个问题,如果我写成
$filename = "//172.16.18.123/news/pic/2012.png";还是找不到。news文件夹和pic文件夹都是共享出来的,只是news是pic的上一级。这是怎么回事呢?劳烦您再帮我解答下疑问不甚感激!还有,如果我把2012.png直接放到172.16.18.123的F盘根目录下,代码应该怎么写啊???多谢这位大侠!本人实在菜鸟,不好意思呀!!!
统一资源定位
//机器名或ip/共享名/路径/文件名
今天我又学了一招
统一资源定位
//机器名或ip/共享名/路径/文件名
谢谢这位大侠,不好意思再麻烦你下下~~~~请问这种情况下,如果想保证远程文件的安全性应该怎么做呢?看了手册里面说开启安全模式,PHP会检查脚本与要读取的文件的UID,这个具体是什么意思啊?UID是怎么检查的呢?有没有深入一点的资料推荐一下啊~~~~或者,php.ini里面能不能对远程文件的登录权限做一个设置啊?比如设置它的用户名和密码,这样通过验证了才能打开远程文件。谢谢您!!万分感激 !!期待您的回复哦!!!
无协议声明时,默认协议名是 file 只适用于局域网
如需安全检查,就不能用同一资源定位了。需改用 LDAP
本帖最后由 xuzuning 于 2012-12-18 11:27:22 编辑无协议声明时,默认协议名是 file 只适用于局域网
如需安全检查,就不能用同一资源定位了。需改用 LDAP
谢谢!!我就是想在局域网内简单调用另一台机器上的某个文件,但是用统一资源定位不能进行安全检查,即不能进行用户登录权限的验证。这种情况我如果把目标机器的文件夹映射到本地磁盘,这样子能不能行呢?我代码里这样写$pic="Z:\\data\news\pic\1.jpg";Z是另外那台机器上的文件夹映射到本机的盘符,这样子不行,PHP好像不认识,是不是我写错了呢?请教您了!!总之我只想简单地调用一下一个东西,但是又不想把那台机器上的文件夹完全暴露出来,就是稍微安全一点,请你帮忙解答!!万分感激啊!!!
NET USE
作用:连接计算机或断开计算机与共享资源的连接,或显示计算机的连接信息。
命令格式:net use 〔devicename | *〕 〔computernamesharename〔volume〕〕 〔password | *〕〕 〔/user:〔domainname〕username〕 〔〔/delete〕 | 〔/persistent:{yes | no}〕〕
参数介绍:
键入不带参数的net use列出网络连接。
devicename指定要连接到的资源名称或要断开的设备名称。
computernamesharename服务器及共享资源的名称。
password访问共享资源的密码。
*提示键入密码。
/user指定进行连接的另外一个用户。
domainname指定另一个域。
username指定登录的用户名。
/home将用户连接到其宿主目录。
/delete取消指定网络连接。
/persistent控制永久网络连接的使用。
简单事例:
(1)net use e: YFANGTEMP将YFANGTEMP目录建立为E盘
(2)net use e: YFANGTEMP /delete断开连接
NET USE
作用:连接计算机或断开计算机与共享资源的连接,或显示计算机的连接信息。
命令格式:net use 〔devicename | *〕 〔computernamesharename〔volume〕〕 〔password | *〕〕 〔/user:〔domainname〕username〕 〔〔/delete〕 | 〔/persistent:{yes |……
大侠,我按照你说的试了,把172.16.22.10上的F盘映射到我本机的Z盘,我在命令行是这样输的:net use z: \\172.16.22.10\f$ "password" /user:"administrator",我试了这样是可以的。但是我在PHP里用system函数执行的时候就不行,请您帮我看看,我的代码是:
$cmd="net use z: \\\\172.16.22.10\\f$ \"password\" /user:\"administrator\"";
if(system($cmd))
echo "映射成功";
else echo "映射失败";
请你帮我看看是代码的问题,还是php.ini里面需要配置什么东西才行啊, 我的安全模式是关了的。
谢谢!!!非常感谢您不耐其烦解答我一个菜鸟的弱弱问题。。。!!期待您的回复哦!!~~~
字符 \ 反过来写,就清楚多了
$cmd="net use z: //172.16.22.10/f$ password /user:administrator";
还有 password 是 administrator 的登录口令,要真实的
字符 \ 反过来写,就清楚多了
$cmd="net use z: //172.16.22.10/f$ password /user:administrator";
还有 password 是 administrator 的登录口令,要真实的
谢谢你大侠!!我按照你说的来写了,但是还是不行艾~~~麻烦你再帮我看看:
$cmd="net use z: //172.16.22.10/f$ pass123456 /user:username";
system($cmd);
您看会不会是system函数的问题啊,需要在配置文件里修改什么不呢?
我在命令行里操作是可以的,就是PHP执行不了。
再次感谢您!!~~~~~~~~~~~
请问楼主 最后这个问题解决了吗 我现在也遇到同样的问题了,查了好多资料也没解决。求帮助啊

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Alipay PHP...

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

The application of SOLID principle in PHP development includes: 1. Single responsibility principle (SRP): Each class is responsible for only one function. 2. Open and close principle (OCP): Changes are achieved through extension rather than modification. 3. Lisch's Substitution Principle (LSP): Subclasses can replace base classes without affecting program accuracy. 4. Interface isolation principle (ISP): Use fine-grained interfaces to avoid dependencies and unused methods. 5. Dependency inversion principle (DIP): High and low-level modules rely on abstraction and are implemented through dependency injection.

How to automatically set the permissions of unixsocket after the system restarts. Every time the system restarts, we need to execute the following command to modify the permissions of unixsocket: sudo...

Article discusses late static binding (LSB) in PHP, introduced in PHP 5.3, allowing runtime resolution of static method calls for more flexible inheritance.Main issue: LSB vs. traditional polymorphism; LSB's practical applications and potential perfo

Sending JSON data using PHP's cURL library In PHP development, it is often necessary to interact with external APIs. One of the common ways is to use cURL library to send POST�...

How to debug CLI mode in PHPStorm? When developing with PHPStorm, sometimes we need to debug PHP in command line interface (CLI) mode...

Article discusses essential security features in frameworks to protect against vulnerabilities, including input validation, authentication, and regular updates.
