I followed Jacek's tut to create a image gallery but i'm getting a error
<?php //Script to create thumbnails if (isset($_GET['img'])) { //make thumbnail if (file_exists($_GET['img'])) { //Ignore user action if user click stop ignore_user_abort(TRUE); //set time to create thumbnails set_time_limit(120); //modifies the memory limit to create the thumbnails ini_set('memory_limit', '512M'); $src_size = getimagesize($_GET['img']); if ($src_size === FALSE) { //ATTENTION - for the purpose of this tut its going to be used die but in a Login script that doesn't work because that will die the script and nothing else will be run die('That does not look like a image.'); } $thumb_width = 250; $thumb_height = 200; if ($src_size['mime'] === 'image/jpeg') { $src = imagecreatefromjpeg($_GET['img']); } else if ($src_size['mime'] === 'image/png') { $src = imagecreatefrompng($_GET['img']); } else if ($src_size['mime'] === 'image/gif') { $src = imagecreatefromgif($_GET['img']); } //else { //header(Location: ); $src_aspect = round(($src_size[0] / $src_size[1]), 1); $thumb_aspect = round(($thumb_width / $thumb_height), 1); if ($src_aspect < $thumb_aspect) { //higher //Get the amunt to be reduced, decimal number. $new_size = array( $thumb_width, ($thumb_width / $src_size[0]) * $src_size[1] ); $src_pos = array( 0, (($new_size[1] - $thumb_height) * ($src_size[1] / $new_size[1])) / 2 ); } else if ($src_aspect > $thumb_aspect) { //wider $new_size = array( ($thumb_width / $src_size[1]) * $src_size[0], $thumb_height ); $src_pos = array( (($new_size[0] - $thumb_width) * ($src_size[0] / $new_size[0])) / 2, 0 ); } else { //same shape $new_size = array( $thumb_width, $thumb_height ); $src_pos(0, 0); } if ($new_size[0] < 1) { $new_size[0] = 1; } if ($new_size[1] < 1) { $new_size[1] = 1; } $thumb = imagecreatetruecolor($thumb_width, $thumb_height); /* dst_image - destination src_image - where you copying from dst_x - destination position dst_y - destination position src_x - where you want to start copying from src_y - new size dst_w - new size dst_h src_w src_h */ imagecopyresampled($thumb, $src, 0, 0, $src_pos[0], $src_pos[1], $new_size[0], $new_size[1], $src_size[0], $src_size[1]); if ($src_size['mime'] === 'image/jpeg') { imagejpeg($thumb, "thumbs/{$_GET['img']}"); } else if ($src_size['mime'] === 'image/png') { imagepng($thumb, "thumbs/{$_GET['img']}"); } else if ($src_size['mime'] === 'image/gif') { imagegif($thumb, "thumbs/{$_GET['img']}"); } header("Location: thumbs/{$_GET['img']}"); } die(); } //Create the folder thumbs to store the thumbnails if (is_dir('./image_gallery/thumbs') === FALSE) { mkdir(('./image_gallery/thumbs'), 0744); } $images = glob('*.{jpg,jpeg,png,gif}', GLOB_BRACE); ?> <script type="text/javascript"></script> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8" /> <title></title> <style type="text/css"> a, img{ float: left; padding: 5px; } </style> </head> <body> <?php foreach($images as $image) { if (file_exists("./image_gallery/thumbs/{$image}")) { echo "<a href='{$image}'><img src='thumbs/{$image}' alt='{$image}'/></a>"; } else { echo "<a href='{$image}'><img src='?img=/{$image}' alt='{$image}'/></a>"; } } ?> </body> </html>
Warning: Invalid argument supplied for foreach() in /home/a5510829/public_html/tryout/gallery.php on line 128