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 Quote Link to comment 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); } } ?> Quote Link to comment 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); } } ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.