Jump to content

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.