# ACCEPT GIF, PNG image file type!

**URL:** <https://forum.kirupa.com/t/accept-gif-png-image-file-type/254009>\
**Category:** programming\
**Created:** [March 7, 2008, 8:03am UTC](https://forum.kirupa.com/t/accept-gif-png-image-file-type/254009 "2008-03-07T08:03:01Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![onmosh](https://avatars.discourse-cdn.com/v4/letter/o/958977/32.png) [@onmosh](https://forum.kirupa.com/u/onmosh)\
**Post date:** [March 7, 2008, 8:03am UTC](https://forum.kirupa.com/t/accept-gif-png-image-file-type/254009/1 "2008-03-07T08:03:01Z")

</div>

Its way to upload a image but only jpeg not png and gif. anyone can give any idea?

```php

$size = 224; // the thumbnail height
    $filedir = $_SESSION["sessioname"] . '/'; // the directory for the original image
    $thumbdir = $_SESSION["sessioname"] . '/'; // the directory for the thumbnail image
    $prefix = 'small_'; // the prefix to be added to the original name
    $maxfile = '200000';
    $mode = '0666';
    $userfile_name = $_FILES['image']['name'];
    $userfile_tmp = $_FILES['image']['tmp_name'];
    $userfile_size = $_FILES['image']['size'];
    $userfile_type = $_FILES['image']['type'];
    if (isset($_FILES['image']['name'])) 
    {
        $prod_img = $filedir.$userfile_name;
        $prod_img_thumb = $thumbdir.$prefix.$userfile_name;
        move_uploaded_file($userfile_tmp, $prod_img);
        chmod ($prod_img, octdec($mode));
        $sizes = getimagesize($prod_img);
        $aspect_ratio = $sizes[0]/$sizes[1]; 
        if ($sizes[0] <= $size)
        {
            //$new_width = $sizes[0];
            //$new_height = $sizes[1];
            $new_width = 216;
            $new_height = 224;
        }else{
            //$new_width = $size;
            //$new_height = abs($new_width/$aspect_ratio);
            $new_width = 216;
            $new_height = 224;
        }
        $destimg=ImageCreateTrueColor($new_width,$new_height) or die('Problem In Creating image');
        $srcimg=ImageCreateFromJPEG($prod_img) or die('Problem In opening Source Image');

        ImageCopyResized($destimg,$srcimg,0,0,0,0,$new_width,$new_height,ImageSX($srcimg),ImageSY($srcimg)) or die('Problem In resizing');
        ImageJPEG($destimg,$prod_img_thumb,90) or die('Problem In saving');
        imagedestroy($destimg);

```
