mediabob Posted August 6, 2007 Share Posted August 6, 2007 Hi, I am trying to create a file manager for my website where users can upload and delete files. The idea is that each user will have a folder created on the server named as their user name. I would like the folder to be created automatically when the open the file manager for the first time, but I can't seem to create the directory. Everything works great as long as the directory exist, but basically when they open their file manager I need to check if the directory named as their user name exists, and if not I need to create it. This is what I have tried but it fails to create the directory, if I manually create the directory the code works to open the file manager it just does not work to create the directory if its not there. $name is passed via URL parameter if (isset($_GET['name']) && (!file_exists('../uploaded/'.$name.'/'))) { mkdir("../uploaded/'.$name.'/"); $directory = (get_magic_quotes_gpc()) ? $_GET['name'] : addslashes($_GET['name']); } else if (isset($_GET['name']) && file_exists('../uploaded/'.$name.'/')){ $directory = (get_magic_quotes_gpc()) ? $_GET['name'] : addslashes($_GET['name']); } Thanks for any help, I am still trying to learn this stuff Quote Link to comment https://forums.phpfreaks.com/topic/63503-solved-help-with-making-directory/ Share on other sites More sharing options...
Fadion Posted August 6, 2007 Share Posted August 6, 2007 mkdir("../uploaded/'.$name.'/"); u are concatenating inside double quotes and im not pretty sure it works, so try making it like this: mkdir("../uploaded/$name"); mkdir should work without problems while the string directory name is valid. If u can create directories using smth like mkdir('testdir') then its not permissions problem, but syntax. Quote Link to comment https://forums.phpfreaks.com/topic/63503-solved-help-with-making-directory/#findComment-316767 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.