Jump to content

A "My Uploads" page?


JustinMs66@hotmail.com

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]
Link to comment
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?
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.