illuz1on Posted July 27, 2007 Share Posted July 27, 2007 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 More sharing options...
stephan.gerlach Posted July 27, 2007 Share Posted July 27, 2007 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 https://forums.phpfreaks.com/topic/62015-displaying-uploaded-files/#findComment-308747 Share on other sites More sharing options...
illuz1on Posted July 27, 2007 Author Share Posted July 27, 2007 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 https://forums.phpfreaks.com/topic/62015-displaying-uploaded-files/#findComment-308752 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.