Jump to content

Displaying uploaded files


illuz1on

Recommended Posts

Hey,

 

I have a file upload form, and im now trying to make a display page that will display the files in a folder.

 

I want each file to be displayed as a picture - so that the picture links to downloading a file (just a pic of a file)

 

If anyone can gimme a guideline on how to do it, will be much appreciated.

 

Thanks

Link to comment
Share on other sites

What about this one?

 

<?php
$dir = "YOUR/DIRECTORY/HERE";

// Open a known directory, and proceed to read its contents
if (is_dir($dir)) {
    if ($dh = opendir($dir)) {
        while (($file = readdir($dh)) !== false) {
            if ($file!='.' && $file!='..') {
                echo "filename: $file \n";
            }
        }
        closedir($dh);
    }
}
?> 

Link to comment
Share on other sites

Thats exactly it, thanks man - just added a image display insead of text

 

Ok so now if I wanted to attach a description to each file, trying to avoid mysql but if I need to I will use it, how would I do it in a flatfile system?

 

Im thinking maybe each file uploaded gets a .txt added to the upload dir with the same filename, and gets the DESCRIPTION field from the upload.html?

 

 

<?php

$dir = "YOUR/DIRECTORY/HERE";

 

// Open a known directory, and proceed to read its contents

if (is_dir($dir)) {

    if ($dh = opendir($dir)) {

        while (($file = readdir($dh)) !== false) {

            if ($file!='.' && $file!='..') {

                echo "<a href="$file"><img src=\"file.jpg\" width=\"20\" height=\"20\" border=\"0\"></a> \n";

            }

        }

        closedir($dh);

    }

}

?>

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.