简体   繁体   English

PHP查找其他顶部文件夹中的文件是否存在

[英]PHP find if file in different top folder exists

What i want to do is find if a file in a different top folder exists. 我想做的是查找是否存在其他顶部文件夹中的文件。

Lets say I want to access the file this "page".html , I would have to access it like: 假设我要访问此文件this "page".html ,我必须像这样访问它:

file_exists('../data/pages/this "page".html')

But that wont work, it just returns false. 但这不会起作用,它只会返回false。 Any suggestions? 有什么建议么?

i am making a flat file cms, so filenames can have quotes. 我正在制作平面文件cms,因此文件名可以带有引号。 url: http://ffcms.comxa.com/admin user: tann98 pass: pswd 网址: http ://ffcms.comxa.com/admin用户:tann98通过:pswd

Thanks in advance. 提前致谢。

Try this 尝试这个

file_exists('../data/pages/this%20"page".html');

%20 for space character 空格字符为%20

file_exists works on the file system and not via HTTP. file_exists在文件系统上工作,而不是通过HTTP。 So %20 will not be recognized as space but literally as %20 use spaces instead: 因此%20将不会被识别为空格,而实际上是%20使用空格代替:

并确保使用dirname( FILE )真正从正确的文件夹开始-如果您的函数调用在包含的文件中,这很重要...

file_exists(dirname(__FILE__).'/../data/pages/this page.html')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM