The14thGOD Posted May 10, 2008 Share Posted May 10, 2008 I'm trying to create a directory if the user needs to create a new category for something. I looked here: http://www.php.net/manual/en/function.mkdir.php and I still can't seem to get it to work. I've got this right now: <?php if($newcategory) { mkdir("..\images\$newcategory",0777); $uploaddir = "../images/$newcategory/";?> It just created the directory "..\images$newcategory" in the same folder as the script. I'm guessing that the \ in front of the $ is just making it ignore the variable so it's not parsing it. Anyone know how to make the directory so it goes back one folder? The server is using PHP 4.4.4 if that helps and running on Linux. Thanks for any help. Justin Quote Link to comment https://forums.phpfreaks.com/topic/104968-solved-creating-a-directory/ Share on other sites More sharing options...
jonsjava Posted May 10, 2008 Share Posted May 10, 2008 <?php if($newcategory) { mkdir("..\\images\\$newcategory",0777); $uploaddir = "../images/$newcategory/";?> Quote Link to comment https://forums.phpfreaks.com/topic/104968-solved-creating-a-directory/#findComment-537301 Share on other sites More sharing options...
The14thGOD Posted May 10, 2008 Author Share Posted May 10, 2008 ah, it got the full name however it still put it in the same directory as the script. it didn't go back out and into the images folder. Quote Link to comment https://forums.phpfreaks.com/topic/104968-solved-creating-a-directory/#findComment-537302 Share on other sites More sharing options...
DarkWater Posted May 10, 2008 Share Posted May 10, 2008 Linux uses /, not \. Quote Link to comment https://forums.phpfreaks.com/topic/104968-solved-creating-a-directory/#findComment-537303 Share on other sites More sharing options...
jonsjava Posted May 10, 2008 Share Posted May 10, 2008 <?php if($newcategory) { mkdir("../images/$newcategory",0777); $uploaddir = "../images/$newcategory/";?> does that do it? Quote Link to comment https://forums.phpfreaks.com/topic/104968-solved-creating-a-directory/#findComment-537304 Share on other sites More sharing options...
The14thGOD Posted May 10, 2008 Author Share Posted May 10, 2008 yep that worked. i don't know why though. i tried it earlier and it gave me an error regarding the function. i might have just mistyped something. ty all justin Quote Link to comment https://forums.phpfreaks.com/topic/104968-solved-creating-a-directory/#findComment-537313 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.