开发者

PHP is_file and server root relative paths

How ca开发者_运维知识库n I use is_file with a path like: /folder/file.jpg please?

Thank you!


If the path starts with a / this means the path is absolute. When the path is relative (ie not starting with /) then the path relative to the php script is taken. If you want to have /folder/file.jpg relative to the server root, you can append the root.

$path = $_SERVER['DOCUMENT_ROOT'] . '/folder/file.jpg';


Use $_SERVER['DOCUMENT_ROOT']:

$is_file = is_file($_SERVER['DOCUMENT_ROOT'] . '/folder/file.jpg');
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜