在网络驱动器的Windows中使用PHP的fopen [英] Using PHP's fopen in windows on a network drive

查看:156
本文介绍了在网络驱动器的Windows中使用PHP的fopen的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码:

$file_name = "1234";
$filename = "L:\\videoette_converter\\batch_files\\".$file_name.'.bat';
if (!$handle = fopen($filename, 'a')) {
     echo "Cannot open file ($filename)";
     exit;
}

我从该代码中收到以下错误:

I get the following error from that code:

警告:fopen(L:\ videoette_converter \ batch_files \ 1234.bat) [function.fopen]:无法打开流:在目录中没有这样的文件或目录 C:\ wamp \ www \ videoette_converter \ index.php,第47行

Warning: fopen(L:\videoette_converter\batch_files\1234.bat) [function.fopen]: failed to open stream: No such file or directory in C:\wamp\www\videoette_converter\index.php on line 47

和我的php中的调试行

and the debug line from my php

无法打开文件(L:\ videoette_converter \ batch_files \ 1234.bat)

Cannot open file (L:\videoette_converter\batch_files\1234.bat)

但是,文件夹L:\videoette_converter\batch_files确实作为映射驱动器存在,并且我已经赋予所有人"完全权限.可能是什么问题?

However the folder L:\videoette_converter\batch_files does exist as a mapped drive, and I have given "Everyone" full permissions. What could be the problem?

推荐答案

您确定没有域控制器吗?

Are you sure there's no domain controller in the way?

当提供文件的Windows计算机位于Active Directory域中时:

When the Windows machine that serves the files is in an Active Directory domain:

1)运行WAMP的计算机必须位于同一域中.

1) The machine that runs the WAMP must be in the same domain.

2)用于在WAMP机器上运行Apache服务的帐户必须至少对要访问的共享具有读取权限.您应该指定域用户帐户,而不是将Apache服务作为本地系统"或"wampapache"运行. (注:我喜欢XAMPP胜过Wamp来进行这种开发,但这可能只是个人喜好)

2) The account used to run the Apache service on your WAMP machine must have at least read rights on the share you want to access. Instead of running the Apache service as "Local System" or "wampapache" you should specify your domain user account. (P.S.: I like XAMPP over Wamp for this kind of development, but that's probably just a personal preference)

此外,如果您使用UNC路径而不是驱动器号,我想我的ID会更好.那样总是对我有用.您不需要使用转义的反斜杠,可以将它们替换为单个正斜杠:

Also I'm guessing id'd be better if you used a UNC path instead of a drive letter. It always worked for me that way. You don't need to use escaped backslashes, you can replace them with single forward ones:

//yourwinserver/sharename/path/to/file.bat

//yourwinserver/sharename/path/to/file.bat

这篇关于在网络驱动器的Windows中使用PHP的fopen的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆