PHP mkdir 问题
Warning: mkdir() [function.mkdir]: No such file or directory in
当我尝试创建新目录时,我不断收到这条恼人的消息。我的函数是
mkdir("../".$a."/".$b);
$a = an existing filepath
$b = new folder i wish to create
从另一个目录执行的函数:我的结构如下所示:
/htroot/site/c/ <- where im executing the function
/htroot/site/a/b <- where i wish to create the directories.
如果我执行以下命令,它将创建所需的效果,但与函数位于同一目录中。
mkdir($a."/".$b);
大家好,感谢大家的热烈响应
C:\wamp\www\book\admin\import //is my __DIR__ for that script
C:\wamp\www\book\admin\property // already exists
C:\wamp\www\book\admin\property\name // want i want end result
Warning: mkdir() [function.mkdir]: No such file or directory in
I keep getting this annoying message when trying to create new directories. my function is
mkdir("../".$a."/".$b);
$a = an existing filepath
$b = new folder i wish to create
function is executed from another directory: my structure looks like this:
/htroot/site/c/ <- where im executing the function
/htroot/site/a/b <- where i wish to create the directories.
if i execute the following, it creates the desired effect but in the same directory as the function.
mkdir($a."/".$b);
HI ALL THANKS FOR THE HOT RESPONSES
C:\wamp\www\book\admin\import //is my __DIR__ for that script
C:\wamp\www\book\admin\property // already exists
C:\wamp\www\book\admin\property\name // want i want end result
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
根据您的功能的包含方式,PWD 可以位于任何位置。最好使用绝对路径。
您还可以使用
__DIR__
(v5.3+) 或dirname(__FILE__)
获取当前脚本的目录,例如
参见 realpath()
Depending on how your function is included, the PWD could be anywhere. You're best to use an absolute path.
You can also grab the current script's directory using
__DIR__
(v5.3+) ordirname(__FILE__)
For example
See realpath()
无论
"../$a"
是什么,无论您多么希望有这样的目录,都不存在。也许有一个符号链接,并且..
不是您认为的目录。Whatever
"../$a"
is, there's no such directory, however much you want there to be. Maybe there's a symlink, and..
isn't the directory you think it is.