为什么我无法使用 php 创建目录?

发布于 2024-10-21 04:08:37 字数 646 浏览 5 评论 0原文

我有一个用户可以上传图像的表单。我有另一个已经可以使用的页面,然后创建一个目录并将图像放入其中。由于某种原因,当我将相同的代码复制到当前页面时,它会出现以下错误:

警告: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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

爱你是孤单的心事 2024-10-28 04:08:37

使用 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 :

var_dump(realpath('../upload/'));

以检查该目录是否为你的想法 - 它将显示其完整路径(如果存在);如果没有,则为 false。

Using mkdir with two parameters, in order to create the directory a/b/c, the directory a/b must exist.

If you want a/b to be created when you try to create a/b/c, you need to pass true as a third parameter (the one called recursive ;-) ) to mkdir.

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 :

var_dump(realpath('../upload/'));

to check if that directory is what you think -- it'll display its full path if it exists ; or false if it doesn't.

穿越时光隧道 2024-10-28 04:08:37
you are passing wrong path to the function man.

即 move_upload_file($arg);

如果你在 $arg 中给出了错误的路径,它将显示你所说的错误消息。

you are passing wrong path to the function man.

i.e move_upload_file($arg);

If u give wrong path in $arg,it will show the error msg as u said.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文