0

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

警告:mkdir() [function.mkdir]:第 251 行的 /home5/ideapale/public_html/amatorders_final/user_char_upload.php 中没有这样的文件或目录

这是它所指的代码:

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 函数在这个页面上对我不起作用。有什么想法吗?

4

2 回答 2

3

使用mkdir两个参数,为了创建目录a/b/c,目录a/b必须存在。

如果您想a/b在尝试创建时被创建a/b/c,则需要true作为第三个参数(称为recursive;-))传递给mkdir.


如果您upload的目录已经存在,那么,您需要确保这../upload/确实是您的想法。

../upload/是相对于当前执行目录的(不一定与包含您的脚本的目录相同!)


您可能想尝试使用这个:

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

检查该目录是否是您所想的——如果存在,它将显示其完整路径;如果没有,则为 false。

于 2011-03-11T12:16:37.057 回答
0
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.

于 2011-03-11T12:41:06.077 回答