为什么我无法使用 php 创建目录?
我有一个用户可以上传图像的表单。我有另一个已经可以使用的页面,然后创建一个目录并将图像放入其中。由于某种原因,当我将相同的代码复制到当前页面时,它会出现以下错误:
警告:mkdir() [function.mkdir]:否 这样的文件或目录 /home5/ideapale/public_html/amatorders_final/user_char_upload.php 第251行
这是它所引用的代码:
if (!file_exists("../upload/" . $order_id . '_' . $row['last_name'])) { //Checks if the directory already exists
mkdir("../upload/" . $order_id . '_' . $row['last_name'], 0755); //Creates a new directory with the order_id and Customer last name
}
我尝试回显所有这些变量,所以我知道它们有效。
对我来说这似乎非常简单,所以我不确定为什么 mkdir 函数在此页面上对我不起作用。有人有什么想法吗?
I have a form where users can upload an image. I have another page which already works that then creates a directory and places the image in it. For some reason, when I copy that same code to my current page, it gives me the following error:
Warning: mkdir() [function.mkdir]: No
such file or directory in
/home5/ideapale/public_html/amatorders_final/user_char_upload.php
on line 251
Here is the code it is referring to:
if (!file_exists("../upload/" . $order_id . '_' . $row['last_name'])) { //Checks if the directory already exists
mkdir("../upload/" . $order_id . '_' . $row['last_name'], 0755); //Creates a new directory with the order_id and Customer last name
}
I tried echoing out all those variables, so I know they work.
It seems pretty straighforward to me, so i'm not sure why the mkdir function isn't working for me on this page. Any ideas anyone?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用
mkdir
和两个参数,按顺序要创建目录a/b/c
,目录a/b
必须存在。如果您希望在尝试创建
a/b/c
时创建a/b
,则需要将true
作为第三个参数传递(称为递归
;-))到mkdir
。If you `upload` directory already exists, then, you need to make sure that `../upload/` is actually what you think.
此
../upload/
相对于当前执行目录(不一定与包含脚本的目录相同!),You might want to try using this :
以检查该目录是否为你的想法 - 它将显示其完整路径(如果存在);如果没有,则为 false。
Using
mkdir
with two parameters, in order to create the directorya/b/c
, the directorya/b
must exist.If you want
a/b
to be created when you try to createa/b/c
, you need to passtrue
as a third parameter (the one calledrecursive
;-) ) tomkdir
.If you `upload` directory already exists, then, you need to make sure that `../upload/` is actually what you think.
This
../upload/
is relative to the current directory of execution (which is not necessarily the same as the one that contains your script !)You might want to try using this :
to check if that directory is what you think -- it'll display its full path if it exists ; or false if it doesn't.
即 move_upload_file($arg);
如果你在 $arg 中给出了错误的路径,它将显示你所说的错误消息。
i.e move_upload_file($arg);
If u give wrong path in $arg,it will show the error msg as u said.