在保持比例的同时调整图像大小

I read here http://php.net/manual/en/function.imagecopyresized.php, that I should use the following code to resize an image while keeping the proportions:

function resizeImage($filename, $max_width, $max_height)
{
    list($orig_width, $orig_height) = getimagesize($filename);

    $width = $orig_width;
    $height = $orig_height;

    # taller
    if ($height > $max_height) {
        $width = ($max_height / $height) * $width;
        $height = $max_height;
    }

    # wider
    if ($width > $max_width) {
        $height = ($max_width / $width) * $height;
        $width = $max_width;
    }

    $image_p = imagecreatetruecolor($width, $height);

    $image = imagecreatefromjpeg($filename);

    imagecopyresampled($image_p, $image, 0, 0, 0, 0, 
                                     $width, $height, $orig_width, $orig_height);

    return $image_p;
}

However, I'm not sure what I should put for the parameter, $filename. I have this code $target_file = ($_FILES["fileToUpload"]["name"]);. Could my $target_file variable be put in for the parameter $filename to be resized? For example,

    $image = addslashes(file_get_contents($_FILES['fileToUpload']['tmp_name']));
    $max_width = 100; 
    $max_height = 100;
    $image = resizeImage($image, $max_width, $max_height);

Would this resize the image to be 100x100?