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?
Using
mkdirwith two parameters, in order to create the directorya/b/c, the directorya/bmust exist.If you want
a/bto be created when you try to createa/b/c, you need to passtrueas 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.