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
https://forums.phpfreaks.com/topic/62015-displaying-uploaded-files/
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);
    }
}
?> 

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);

    }

}

?>

Archived

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

×
×
  • 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.