How to display image from server (newest-oldest) to a new php page?
Posted
by
Jben Kaye
on Stack Overflow
See other posts from Stack Overflow
or by Jben Kaye
Published on 2013-10-27T09:37:17Z
Indexed on
2013/10/27
9:54 UTC
Read the original article
Hit count: 207
php
i have a form that create images and save it on a folder in the server. What i need to do is to display ALL created images to another page, the newest on the top and so that the oldest is at the bottom. i have a form called formdisplay.php but it's just displaying a broken image and not newest to oldest. hope you can help me with this. really need to get this working. thanks in advance for your help.
i have read the posts but none of those worked for me.
Pull dedicated images from folder - show image + filename (strip part of filename + file-extension)
How can I display latest uploaded image first? (PHP+CSS)
getting images from the server and display them
Displaying images from folder in php
display image from server embedding php in html
formcreatesave.php
imagecopymerge($im, $img2, 10, 350, 0, 0, imagesx($img2), imagesy($img2), 100);
$date_created = date("YmdHis");//get date created
$img_name = "-img_entry.jpg"; //the file name of the generated image
$img_newname = $date_created . $img_name; //datecreated+name
$img_dir =dirname($_SERVER['SCRIPT_FILENAME']) ."/". $img_newname; //the location to save
imagejpeg($im, $img_dir , 80); //function to save the image with the name and quality
imagedestroy($im);
formdisplay.php
$dir = '/home3/birdieon/public_html/Amadeus/uploader/uploader';
$base_url = 'http://birdieonawire.com/Amadeus/uploader/uploader/20131027024705-img_entry.jpg';
$newest_mtime = 0;
$show_file = 'BROKEN';
if ($handle = opendir($dir)) {
while (false !== ($file = readdir($handle))) {
if (($file != '.') && ($file != '..')) {
$mtime = filemtime("$dir/$file");
if ($mtime > $newest_mtime) {
$newest_mtime = $mtime;
$show_file = "$base_url/$file";
}
}
}
}
print '<img src="' .$show_file. '" alt="Image Title Here">';
please feel free to edit my code. thanks :)
© Stack Overflow or respective owner