I am new to php and I need help. I am trying to make a simple image gallery. I am done with uploading part of my gallery. Now I want to get those images from a folder, make their thumbnails and save them in an array so that I can display them later. This is what I am struggling with so far. The array remains null at the end.
$folder = 'images/';
$filetype = '*.*';
$files = glob($folder.$filetype);
$count = count($files);
$thumbArray = array();
for($i=0; $i<$count; $i++){
if(($img = @imagecreatefromstring($files[$i])) !== FALSE) {
$width = imagesx($img);
$height = imagesy($img);
$boxSize = min($width,$height);
$boxX = ($width / 2) - ($boxSize / 2);
$boxY = ($height / 2) - ($boxSize / 2);
$thumbArray[$i] = imagecreatetruecolor(100, 100);
imagecopyresampled($thumbArray[$i], $img, 0, 0, $boxX, $boxY, 100, 100, $boxSize, $boxSize);
}
}
Thanks in advance.