samedi 9 août 2014

php - affichage de l'image webcam dernière en miniature - Stack Overflow


I've been trying for days to display a thumbnail of my weather cam. The server path is as follows


public_html ..cam ...20121012 ...20121013 ...20121014


The date folder are auto created everyday by my webcam settings. So everyday it will create a new folder and name it date('Ymd').


I'm using the following script to have the image displayed on my wordpress sidebar, but I can't get it to work. Furthermore, I would like to have it displayed as a thumbnail and when a visitor clicks on it, to have it open slightly larger (real size) in a popup screen.


<?php
chdir('/home/deb57301n2/domains/meteowestkust.be/public_html/cam/');
$subdirname = date('Ymd').'/';
echo getcwd();
$newest_mtime = 0;
$show_file = 'webcam_offline.png';
if ($handle = opendir($subdirname)) {
while (false !== ($file = readdir($handle))) {
if (($file != '.') && ($file != '..')) {
$mtime = filemtime($subdirname.$file);
if ($mtime > $newest_mtime) {
$newest_mtime = $mtime;
$show_file = $subdirname.$file;
}
}
}
}
print '<img src="' .$show_file. '" alt="Weather Cam - West Coast - Belgium">';
?>

any help is highly appreciated !




It worked by adding


$show_file = '/cam/'.$subdirname.$file;


thanks for the help anyway guys !



I've been trying for days to display a thumbnail of my weather cam. The server path is as follows


public_html ..cam ...20121012 ...20121013 ...20121014


The date folder are auto created everyday by my webcam settings. So everyday it will create a new folder and name it date('Ymd').


I'm using the following script to have the image displayed on my wordpress sidebar, but I can't get it to work. Furthermore, I would like to have it displayed as a thumbnail and when a visitor clicks on it, to have it open slightly larger (real size) in a popup screen.


<?php
chdir('/home/deb57301n2/domains/meteowestkust.be/public_html/cam/');
$subdirname = date('Ymd').'/';
echo getcwd();
$newest_mtime = 0;
$show_file = 'webcam_offline.png';
if ($handle = opendir($subdirname)) {
while (false !== ($file = readdir($handle))) {
if (($file != '.') && ($file != '..')) {
$mtime = filemtime($subdirname.$file);
if ($mtime > $newest_mtime) {
$newest_mtime = $mtime;
$show_file = $subdirname.$file;
}
}
}
}
print '<img src="' .$show_file. '" alt="Weather Cam - West Coast - Belgium">';
?>

any help is highly appreciated !



It worked by adding


$show_file = '/cam/'.$subdirname.$file;


thanks for the help anyway guys !


0 commentaires:

Enregistrer un commentaire