Hi,
I am trying to write a script that creates a new folder made up of a given username, it works:
<?php
$username = $_POST['username'];
$targetdirectory = "usr/bin/";
mkdir($targetdirectory.$username,0755,true);
?>
What I want is the script to create the folder back two folders, i.e. …/…/usr/bin/$username
How do I get it to point two directories up? I’ve tried:
<?php
$username = $_POST['username'];
$targetdirectory = "../../usr/bin/";
mkdir($targetdirectory.$username,0755,true);
?>
but no joy.
Any help is greatly appreciated!
Thanks.
AJ
does PHP have access to write into/make folders in that directory?
Yes it does - well at least I think it does.
The directory should be created in:
public_html/xxxxx/usr/bin/
The script that is do achieve that is:
public_html/xxxxx/admin/user/parse_user.php
I hope that makes sense.
does public_html/xxxxx/usr/bin exist?
i think your problem may be that you are trying to use a relative path to create these folder. I would suggest creating some sort of config file or if you already have one creating a variable that contains a absolute path to the folder.
example:
$config[‘base_path’] = ‘/home/public_html/’;
then you can use this later on in your script:
$targetDir = $config[‘base_path’] . ‘bin/usr/’;
Hope that makes sense
StartLion - yes that directory exists. I want to create a new folder within that directory with the name = $username (when a user is added to the database).
Hansie - thanks for that, that would be a good idea, I can then use it for removing a directory when a user is deleted.