php 获取虚拟目录

WBOY
Release: 2016-06-23 13:47:29
Original
1331 people have browsed it

各位大牛,请教一个问题。
我现在是在iis下配置的php网站,然后在站点下建了一个uploadfile的虚拟目录,请问下如何获取这个虚拟目录的真实路径?比如我想上传文件或者判断此目录中是否存在某个文件is_file('/uploadfile/xxxxxxxxxxxxxxxxxx')永远都是false,有什么简便的方法么?不太想去写配置定绝对路径~


回复讨论(解决方案)

is_file('uploadfile/xxxxxxxxxxxxxxxxxx')

你可在 uploadfile 指向的目录中建一 php 文件,比如 info.php

<?phpecho __DIR__;
Copy after login
Copy after login

在需要获得 uploadfile 真实路径的程序里
$path = file_get_contents('http://localhost/uploadfile/info.php');
Copy after login
Copy after login

你可在 uploadfile 指向的目录中建一 php 文件,比如 info.php

<?phpecho __DIR__;
Copy after login
Copy after login

在需要获得 uploadfile 真实路径的程序里
$path = file_get_contents('http://localhost/uploadfile/info.php');
Copy after login
Copy after login


这个建议不错,感谢~
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template