windows下php访问网络路径

2022-11-09php开发问题
1

本文介绍了windows下php访问网络路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

在安装在 Windows XP 计算机上的 PHP (XAMPP) 中我试图读取本地网络服务器上存在的目录.我使用 is_dir() 来检查它是否是我可以读取的目录.

within PHP (XAMPP) installed on a Windows XP Computer Im trying to read a dir which exists on a local network server. Im using is_dir() to check whether it is a dir that I can read.

在 Windows 资源管理器中,我输入 \serverdir 并显示该目录.当我映射网络驱动器时,也可以使用 z:dir 访问它.

In Windows Explorer I type \serverdir and that dir is being shown. When I map a network drive a can access it with z:dir as well.

在 PHP 中我有那个脚本:

In PHP I have that script:

<?php if( is_dir($dir){ echo 'success' } ) ?>

对于 $dir 我试过:

  • /server/dir
  • //server/dir
  • serverdir
  • \serverdir
  • \\server\dir

  • z:dir
  • z:\dir
  • z:/dir
  • z://dir

但我从来没有成功过?任何的想法?谢谢

But I never get success? Any idea? thx

推荐答案

我通过更改服务器注册表中的一些内容解决了这个问题,如本次讨论的最后一个答案所述:

I solved it by changing some stuff in the registry of the server as explained in the last answer of this discussion:

http://bugs.php.net/bug.php?id=25805

无论如何都要感谢 VolkerK 和 Gumbo!我喜欢 stackoverflow 和他们很棒的人,他们帮助你的速度非常快!!

Thanks to VolkerK and Gumbo anyway! I love stackoverflow and their great people who help you so incredibly fast!!

编辑(取自 php.net):

EDIT (taken from php.net):

该服务对网络资源的访问受限,例如共享和管道,因为它没有凭据并且必须使用 null 进行连接会议.以下注册表项包含 NullSessionPipes 和NullSessionShares 值,用于指定管道和空会话可以连接到的共享:HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesLanmanServerParameters或者,您可以添加 REG_DWORD 值RestrictNullSessAccess 键值,设置为 0 允许所有空值会话以访问在该机器上创建的所有管道和共享.`

The service has limited access to network resources, such as shares and pipes, because it has no credentials and must connect using a null session. The following registry key contains the NullSessionPipes and NullSessionShares values, which are used to specify the pipes and shares to which null sessions may connect: HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesLanmanServerParameters Alternatively, you could add the REG_DWORD value RestrictNullSessAccess to the key and set it to 0 to allow all null sessions to access all pipes and shares created on that machine.`

将 RestrictNullSessAccess=0 添加到您的注册表中.

add RestrictNullSessAccess=0 to your registery.

这篇关于windows下php访问网络路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

PHP实现DeepL翻译API调用
DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以...
2025-08-20 php开发问题
168

PHP通过phpspreadsheet导入Excel日期数据处理方法
PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的...
2024-10-23 php开发问题
287

mediatemple - 无法使用 codeigniter 发送电子邮件
mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)...
2024-08-23 php开发问题
11

Laravel Gmail 配置错误
Laravel Gmail Configuration Error(Laravel Gmail 配置错误)...
2024-08-23 php开发问题
16

将 PHPMailer 用于 SMTP 的问题
Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)...
2024-08-23 php开发问题
4

关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题
Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)...
2024-08-23 php开发问题
17