Jump to content

Archived

This topic is now archived and is closed to further replies.

JustinMs66@hotmail.com

A "My Uploads" page?

Recommended Posts

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:

[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);
}
?>[/code]

Share this post


Link to post
Share on other sites
k i figured this out, so "$session['uname'] is the logged in username, and so thisis the code i made:
[code]<?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);
}
?>[/code]


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?

Share this post


Link to post
Share on other sites

×

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.