Making thumbnails with GD Library

I’ve made an upload form that allows you to upload images and I want to use the GD Library to store a thumbnail of the image in the same directory. When I submit the form though it displays the path to the php file in the browser(e.g. http://localhost/thumbform.php). I think the problem lies in the line with the “Header”, can someone tell me where I’m going wrong?


<?php    
    if(isset($_POST['submit'])) {        
        // This sets the variables for my posted file & destination directory
        $img_info = $_FILES['img_file'];    
        $img_name = $img_info['name'];
        $img_type = $img_info['type'];
        $tmp_name = $img_info['tmp_name'];
        $img_size = $img_info['size'];
        $destination = "thumbs";
        
        // This is where the file is moved into the destination directory
        $temp_place = $_FILES['img_file']['tmp_name'];
        $move_result = move_uploaded_file($temp_place, $destination."/".$img_name);
        if(!$move_result) {
            die("Upload was not complete.");
        }
    
        // And this is where the thumbnail is meant to be created and then moved to the same directory.
        $img_name = $_POST['img_name'];
        $save = "{$destination}/tn_{$img_name}";
        $file = '{$img_name}';          
        $size = 0.45;
        header('Content-type: image/jpeg') ;
        list($width, $height) = getimagesize($file) ;
        $modwidth = $width * $size;
        $modheight = $height * $size;
        $tn = imagecreatetruecolor($modwidth, $modheight) ;
        $image = imagecreatefromjpeg($file) ;
        imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ;
        imagejpeg($tn, $save, 100) ;
    }
?>