PHP 目录位置
我不明白如何保存目录位置。
该脚本位于根目录的某个子文件夹中。这是示例树:
|-index.php
|-another.php
|+empty_folder
|+subfolder
|---script.php
我从 script.php
运行。我必须保存 empty_folder
的数据库路径。在脚本中我使用代码:
if (is_writable($PATH)) ...
并且每次都会返回错误(无法打开文件夹)。现在 $PATH
看起来像 ../empty_folder
并且这不起作用。
有什么办法吗?
I can't understand how to save directory location.
The script is located in some subfolder of root one. Here is the example tree:
|-index.php
|-another.php
|+empty_folder
|+subfolder
|---script.php
I'm running from script.php
. I have to save in database path for the empty_folder
. In script I use the code:
if (is_writable($PATH)) ...
And it returns error every time (can't open the folder). Now $PATH
looks like ../empty_folder
and this doesn't work.
Any ways?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
而不是 ../ 尝试使用完整路径:
if(is_writeable('/srv/http/wordpress/'))
Instead of ../ try the use of the full path:
if(is_writeable('/srv/http/wordpress/'))
仅当当前用户 ID 无法写入指定路径时,is_writable 才会返回 false。这可能是因为该路径不存在,或者当前用户 ID 没有可写入的内容。
empty_folder 的权限是什么(用户/组+权限)以及您的脚本在哪个用户ID/组ID(Web 服务器的?)下运行。
is_writable only returns false if the specified path cannot be written to by the current user ID. That can be because the path doesn't exist, or the current user ID doesn't have the writes to write there.
What are the permissions on empty_folder (user/group + permissions) and what userID/groupID is your script running under (web server's?).