PDA

View Full Version : mkdir trouble


ensinger
07-15-2003, 01:01 AM
When trying to make a directory with:

mkdir ("/printpirate/images/$Email");

I get the following error:

Warning: mkdir() failed (No such file or directory) in c:\phpdev5\www\printpirate\register.php on line 652

Needless to say no directory is created. I'm using windows so mode isn't necessary. What could be causing this, and how can I fix it?

mordred
07-15-2003, 01:07 AM
Does the directory c:\printpirate\images exist? That's the directory in which you try to create the new directory. Check your path again, if you want to create a directory in the images directory relative to register.php, you could try using "images/$email" instead.
Sometimes you have to use an absolute path though.

ensinger
07-15-2003, 06:45 PM
I tried using the full path and that produces no errors and creates a directory. The problem is that rather than naming the directory the with contents of $Email, the directory is named images$Email in the root of the images directory when the path is in double quotes, I tried single quotes (if I'm not mistaken that would cause to not treat the variable as a variable, but tried it anyway), and that craeted a directory by the name of $Email in the images directory.

Is it not possible to create a directory by the name of the value of a variable, or is this achieved in some other way?

raf
07-15-2003, 06:55 PM
Never used mkdir() but apparently you need to include a mode.
http://be.php.net/manual/en/function.mkdir.php

ensinger
07-15-2003, 09:41 PM
I'm running it on windows so mode does not apply according to the manual.

ensinger
07-15-2003, 10:25 PM
I achieved the ideal objective with:

mkdir ("images/$Email");

a preceding slash must specify to create the directory relative to the root of the drive and a forwar slash rather than back must have caused the variable to be interpreted properly.

mordred
07-15-2003, 11:05 PM
That's what I wrote in my answer ("images/$Email"). ;)

ensinger
07-16-2003, 08:46 PM
oops, I was distracted by the absolute path idea and didn't catch it.