Jump to content

[SOLVED] Help with making directory


mediabob

Recommended Posts

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  ::)

Link to comment
https://forums.phpfreaks.com/topic/63503-solved-help-with-making-directory/
Share on other sites

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.