bizerk Posted October 1, 2006 Share Posted October 1, 2006 Alright here is the dealio. I am trying to read a directory where all files are stored whenever a user uploads a file. The upload function is currently scripted in a file named "upload.php", and all the variable names and file extensions are defined in uploads.php as well. What i did was i created a whole new file and called it "allimages.php". At first i had it the file like this:[code]<?$file_dir="users/public";$dir=opendir($file_dir); while ($file=readdir($dir)) { if ($file != "." && $file != "..") { echo "<a href=".$file_dir."/".$file." target=_blank>".$file."</a>"; echo "<br>"; } }?>[/code]what that code would do was Display the File names with a Link that had no extensions at the end so it would read it as a 404 no directory or file. For example: if i uploaded a picture called joe.jpg, my upload.php script would rename the file into the directory: "/users/public/joe.jpg" But this script would make links saying: "/users/public/joe". So than i decided I would do what i did with my upload.php script and just use the include() statement so i could obtain all the variables and values defined in "upload.php" My code now looks like this:<?include("upload.php");$file_dir="users/public";$split_ext = explode(',', $globalvars->settings['allowed_ext']); $split_img = explode('.', $_FILES[$whichfile]['name']); $extcount = count($split_ext);$dir=opendir($file_dir); while ($file=readdir($dir)) { if ($file != "." && $file != "..") { echo "<a href=".$file_dir."/". $split_img[0] . "." . strtolower($split_img[1])." click here to view</a>"; echo "<br>"; } }?>Alright well globalvars is reffering to the Admin settings that admins can change and the split_img is splitting it up into the "name" and the "extension". This should work since i did a A href link in upload.php that looked exactly like this that worked. But when i go to allimages.php the page is jusst blank. It does not have any errors or anything it just is blank. My reasoning for this would be that i did not include("upload.php") correctly or am not understanding what to do wit h"upload.php" if i need to put my whole "upload.php" script up here i will do so, but can anyone help me!? Link to comment https://forums.phpfreaks.com/topic/22689-reading-a-directory-opening-the-directory-and-than-displaying-the-images/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.