I have a script where users sign up for a free account and login and then can store text files and images to their account.. I want to now allow them to create sub directories (folders to organize files) on their account, but since I do not acutally create the files they are just in a database this might be slightly difficult
My solution so far
Add a column named `virtualpath` defaults to "/" (users 'root' folder) then when users create documents they can specify a folder name for instance if they put 'path' for the folder name the `virtualpath` will read `/path/` ...
Then on their file manager page it will show all their folders which they can browse.. i want them to be able to have unlimited subdirectories which means /path/path/1/1/1/1/1/1//1/1/1/1/1//1/1/etc/etc/etc........
I can list their folders with this code
Code: Select all
<? $user = $_SESSION['user'];
$user = secure($user);
$result=mysql_query("SELECT `virtualpath` FROM `texts` WHERE `user` = '$user' group by `virtualpath` ;") or die(mysql_error());
while ( list($path) = mysql_fetch_array($result)) {
echo "<TR><TD>$path</td></tr>";
} ?>The only thing i can think of right now is arrays?
$folders["/"]["path/"]["to/"]["file/"] or something like that... any ideas on simpiler ways to implement this? Or how I would dynamically name the arrays indexes like explodeing the paths i get from the database or something... ugh this is so confuseing