spires Posted October 3, 2006 Share Posted October 3, 2006 Hi, can some tell what part of my code do i need to edit so i can upload GIFS as well as JPGS.Thanks for all your help.[code]if(isset($_POST['thumb_submit'])) { $size = 100; // the thumbnail height $width = 100; // size of width $filedir = 'thumb2_orig/'; // the directory for the original image $thumbdir = 'thumb2/'; // the directory for the thumbnail image $largedir = 'large/'; // the directory for the large image $prefix = ''; // the prefix to be added to the original name $maxfile = '1000000'; // max file size $mode = octdec('0666'); // octdec -- Octal to decimal. // The mode parameter consists of three octal number components specifying access restrictions for the owner, // the user group in which the owner is in, and to everybody else in this order. e.g (666) $userfile_name = $_FILES['thumb']['name']; $userfile_tmp = $_FILES['thumb']['tmp_name']; $userfile_size = $_FILES['thumb']['size']; $userfile_type = $_FILES['thumb']['type']; // if you have a the image and name then carry on if (isset($_FILES['thumb']['name'])) { $new_img_name = $id.$userfile_name; // $prod_img = the image folder and the image and name $prod_img = $filedir.$new_img_name; // $prod_img_thumb = the thumb folder, the prefix (if you want it) and the image and name $prod_img_thumb = $thumbdir.$prefix.$new_img_name; //move_uploaded_file -- Moves an uploaded file to a new location. //move the uploaded file to the image folder with a tempory name. move_uploaded_file($userfile_tmp, $prod_img); // chmod -- Changes file mode, // set the user interface for the image chmod ($prod_img, $mode); // getimagesize -- Get the size of an image // find the size of the original image $sizes = getimagesize($prod_img); $aspect_ratio = $sizes[1]/$sizes[0]; // if its less than the size you want it, dont change if ($sizes[1] <= $size) { $new_width = $sizes[0]; $new_height = $sizes[1]; // else, change image size }else{ $new_height = $size; $new_width = $width; // $new_width = abs($new_height/$aspect_ratio); // this code will only change the height, and make the width in ratio } $destimg=ImageCreateTrueColor($new_width,$new_height) or die('Problem In Creating image2'); $srcimg=ImageCreateFromJPEG($prod_img) or die('Problem In opening Source Image2'); ImageCopyResized($destimg,$srcimg,0,0,0,0,$new_width,$new_height,ImageSX($srcimg),ImageSY($srcimg)) or die('Problem In resizing2'); ImageCopyResampled($destimg, $srcimg, 0, 0, 0, 0, $new_width, $new_height, $sizes[0], $sizes[1]) or die('Problem In resampling2'); ImageJPEG($destimg,$prod_img_thumb,90) or die('Problem In saving2'); imagedestroy($destimg); } [/code] Link to comment https://forums.phpfreaks.com/topic/22910-gifs-help-please/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.