<form action="" method="post" enctype="multipart/form-data" id="something" class="uniForm">
    <input name="new_image" id="new_image" size="30" type="file" class="fileUpload" />
    <button name="submit" type="submit" class="submitButton">Upload/Resize Image</button>

<?php
require 'imgtest.php';
    if(isset($_POST['submit'])){
      if (isset ($_FILES['new_image'])){
          $imagename = $_FILES['new_image']['name'];
          $source = $_FILES['new_image']['tmp_name'];
          
          
          ImageCompressFn($imagename, $source);
          
     /*     $target = "images/".$imagename;
          move_uploaded_file($source, $target);

          $imagepath = $imagename;
          $save = "images/" . $imagepath; //This is the new file you saving
          $file = "images/" . $imagepath; //This is the original file

          list($width, $height) = getimagesize($file) ; 

          $what = getimagesize($file);
            switch(strtolower($what['mime']))
            {
                case 'image/png':
                        $tn = imagecreatetruecolor($width, $height) ; 
                        $image = imagecreatefrompng($file) ; 
                        imagecopyresampled($tn, $image, 0, 0, 0, 0, $width, $height, $width, $height) ; 
                        imagepng($tn, $save, 5) ;
                    break;
                case 'image/jpeg':
                        $tn = imagecreatetruecolor($width, $height) ; 
                        $image = imagecreatefromjpeg($file) ; 
                        imagecopyresampled($tn, $image, 0, 0, 0, 0, $width, $height, $width, $height) ; 
                        imagejpeg($tn, $save, 70) ;
                    break;
                case 'image/gif':
                        $tn = imagecreatetruecolor($width, $height) ; 
                        $image = imagecreatefromgif($file) ; 
                        imagecopyresampled($tn, $image, 0, 0, 0, 0, $width, $height, $width, $height) ; 
                        imagegif($tn, $save, 70) ;
                    break;
                default: die();
            }
        

        // THUMB IMAGE CODE
        
          $save = "images/thumb_" . $imagepath; //This is the new file you saving
          $file = "images/" . $imagepath; //This is the original file

          list($width, $height) = getimagesize($file) ; 

          $modwidth = 300; 
          $modheight = 300; 
          
            switch(strtolower($what['mime']))
            {
                case 'image/png':
                        $tn = imagecreatetruecolor($modwidth, $modheight) ; 
                        $image = imagecreatefrompng($file) ; 
                        imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ; 
                        imagepng($tn, $save, 5) ;
                    break;
                case 'image/jpeg':
                        $tn = imagecreatetruecolor($modwidth, $modheight) ; 
                        $image = imagecreatefromjpeg($file) ; 
                        imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ; 
                        imagejpeg($tn, $save, 70) ;
                    break;
                case 'image/gif':
                        $tn = imagecreatetruecolor($modwidth, $modheight) ; 
                        $image = imagecreatefromgif($file) ; 
                        imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ; 
                        imagegif($tn, $save, 70) ;
                    break;
                default: die();
            }          
          */

        //echo "Large image: <img src='images/".$imagepath."'><br>"; 
        //echo "Thumbnail: <img src='images/sml_".$imagepath."'>"; 

      }
    } 
	
	?>