我很难过,我确信我在这里遗漏了一些非常基本的东西。安全模式已禁用,文件存在。
此代码:
$dir = "textfiles"
chdir('../'.$dir."/");
//using a Windows Slash here(Wamp Stack, on Windows 7 Dev environment
$filename = getcwd() ."\\". $row[0];
//echoing this outputs:
//C:\wamp\www\wordpress\textfiles\New Text Document.txt
$filename = str_replace("\\","\\\\",$filename);
//echoing this outputs C:\\wamp\\www\\wordpress\\textfiles\\New Text Document.txt
//escaping slashes in filename to prevent escaping. I SUSPECT my issue may be
// related to this
//if (file_exists("C:\\wamp\\www\\wordpress\\textfiles\\New Text Document.txt")) {
//Line above is commented out, but when it replaces the line below, this thing
//returns True
if (file_exists($filename)) {echo "Yes";}
else { echo $filename;}
答案 0 :(得分:0)
注释掉
行/* $filename = str_replace("\\","\\\\",$filename); */
您的代码应该有效。