View Full Version : [PHP] Directories
JamesRouale
26-01-2007, 07:04 PM
Hey, I'm currently doing a 'project' for my college, and I need a script which merged with a HTML form could automaticly generate a directory which could later store files as such.
Not much to offer apart from my gratitude. However I will reward reputation, not much of a reward but 'meh...
Thank you, James.
As in, create a directory?
mkdir('/somewhere/newdirectory');
You can also specify the mode of the new directory.
mkdir('/somewhere/newdirectory', 0755);
Robbie
26-01-2007, 10:11 PM
make.php
<?
$directory = $_POST[directory];
mkdir('$directory');
?>
HTML Form
<form action="make.php" method="post">
<input type="text" name="directory"></input>
<input type="submit" name="submit" value="Make the Directory">
</form>
Then type whatever in the textbox
e.g /robbiegray/isthe/best
JamesRouale
26-01-2007, 11:30 PM
Perfect!
Thank you, reputation will be awarded as stated, although it doesn't look like Nets needs any more but 'meh.
Edit'o: Nets I need to spread grr.
Make sure you chmod the make file..
JamesRouale
27-01-2007, 01:30 PM
Permission denied?
JamesRouale
27-01-2007, 02:56 PM
It is...
You need to change the mode of the directory you're creating the new directory in. Also, you might want to check that there's only letters and numbers in the folder's name.
function cd($d) {
$rx = "/^[a-zA-Z1-9]+$/";
return preg_match($rx, $d);
}
Mentor
28-01-2007, 11:05 AM
Make sure your useing the correct abosulte path to the dir you want to create also.
JamesRouale
28-01-2007, 03:33 PM
An example of an absolute path would be?
Mentor
28-01-2007, 04:00 PM
Well it would depend on your sever set up. My public html folders root path is: /home/thybagc/public_html/
for exsample. So if i wanted to create a new folder somewhere i may need to use: /home/thybagc/public_html/somephpapp/files/newfolder1
The bold bit being the folder im creating, the rest just being the path to where i want to create it (ive never actualy used the mkdir function in a php app before, never needed to, so my understanding of it may be wrong, but thats how i belive it works)
Want to hide these adverts? Register an account for free!
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.