0
I have the code below, where it connects in the bank, takes the name of the image and saves in an Array:
while($row = $stm->fetch()) {
echo "<img src=thumb.php?img=".$row['foto']."/>";
}
The file Thumb.php, is who does all the processing of the image to leave in gallery:
$filename = $_GET['img'];
$percent = 0.10;
// Cabeçalho que ira definir a saida da pagina
header('Content-type: image/jpeg');
// pegando as dimensoes reais da imagem, largura e altura
list($width, $height) = getimagesize($filename);
//setando a largura da miniatura
$new_width = 120;
//setando a altura da miniatura
$new_height = 100;
//gerando a a miniatura da imagem
$image_p = imagecreatetruecolor($new_width, $new_height);
$image = imagecreatefromjpeg($filename);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
//o 3º argumento é a qualidade da imagem de 0 a 100
imagejpeg($image_p, null, 50);
imagedestroy($image_p);
The images are in the same directory where you have the index.php that connects in the database and shows the gallery and the file Thumb.php.
The problem that does not display the photo and does not generate any error. It brings back the photo comments that are in the database, but the image does not.
Here $Row['photo'] comes the full name of the photo on md5, example : 8d399117a184a7f243d236930d60eb0b.png . And in the same directory there is a photo with this name.
– user54154
All files, both index.php, both Thumb.php and images are in the same directory. Anyway, I pointed out the current directory as your suggestion, however the same situation occurs. nothing appears.
– user54154
I did this test and failed to open image file .png. I created another file with the same new however in . jpg and now opened the screen all encoded.
– user54154
Now I’m back to the header and the thumbnail opened directly by Thumb.php
– user54154