在php中调整照片大小

This is the code provided in an example at: http://www.php.net/manual/en/function.imagecopyresampled.php

test.jpg size: 500x357

phpdotnet_resize.php

This displays test.jpg resized at 200x142

    <?php
            // The file
            $filename = 'test.jpg';

            // Set a maximum height and width
            $width = 200;
            $height = 200;

            // Content type
            header('Content-Type: image/jpeg');

            // Get new dimensions
            list($width_orig, $height_orig) = getimagesize($filename);

            $ratio_orig = $width_orig/$height_orig;

            if ($width/$height > $ratio_orig) {
               $width = $height*$ratio_orig;
            } else {
               $height = $width/$ratio_orig;
            }

            // Resample
            $image_p = imagecreatetruecolor($width, $height);
            $image = imagecreatefromjpeg($filename);
            imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);

            // Output
            imagejpeg($image_p, null, 100);

 echo "<img src='$filename'>";

    ?>

However, this displays test.jpg in its original size of 500x357

 <?php
       include "phpdotnet_resize.php";
                echo "<img src='$filename'>";
?>

I am trying to move the resized test.jpg to images/ but it keeps moving the original size image.

upload.php (only relevant snippet showing)

  include "phpdotnet_resize.php";
  if(move_uploaded_file($file_tmp,"images/".$filename)){
        echo "Success";