Jump to content


Photo

A "My Uploads" page?


  • Please log in to reply
1 reply to this topic

#1 JustinMs66@hotmail.com

JustinMs66@hotmail.com
  • Members
  • PipPipPip
  • Advanced Member
  • 138 posts

Posted 16 September 2006 - 06:12 PM

hey so i have a working upload script, as well as a working user registration/login thing using mysql, but what i want to do now is have a "my uploads" page. which i believe i know kinda how to do. this is what i want:

i also have a working "show file contents in directory" script, and i want to tweak it so that the directory will change depending on what user is looking at their upload page. because i am going to have a different upload directory per user. so like yea, how would i get it to do that?

btw, here is my show directory script:

Code:

<?php
//tells which directory to open. this is probubly where the tweaked code will go, i dunno tho.
if ($handle = opendir('.')) {
   while (false !== ($file = readdir($handle))) {
       if ($file != "." && $file != ".." && $file != "index.php" && !is_dir($file)) {
         // shows the file name, as well as a link to the file:
           echo "<a href='" . $file . "'>" . $file . "</a><br/>";
       }
   }
   closedir($handle);
}
?>


#2 JustinMs66@hotmail.com

JustinMs66@hotmail.com
  • Members
  • PipPipPip
  • Advanced Member
  • 138 posts

Posted 16 September 2006 - 07:53 PM

k i figured this out, so "$session['uname'] is the logged in username, and so thisis the code i made:
<?php
//this is the new code, making it go to the username folder:
                $username = "uploads/users/" . $_SESSION['Uname'] . "/";
//normal code, but replaced "." with $username, to get it to go to that folder
if ($handle = opendir($username)) {
//end of new code, beginning of normal showing directory code:
   while (false !== ($file = readdir($handle))) {
       if ($file != "." && $file != ".." && $file != "index.php" && $file != "upload.php" && $file != "index.html" && !is_dir($file)) {
           echo "<a href='" . $file . "'>" . $file . "</a><br/>";
       }
   }
   closedir($handle);
}
?>


but it outputs this:

username1
username2

and then has a link to www.mywebsite.com/username1

insted of showing the files in the www.mywebsite.com/uploads/users/username1/ directory.
howdo i fix this?




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users