dear friends, i have the following script that uploads and image and resize (makes main image smaller and also creates a thumbnail).

Currently it only supports jpg files. I want to make some changes i.e.

1. This can support .gif , .png and file formats also
2. Also that we can upload 3 images at a single time (3 image fields) but if i just upload 1 image, this does not give errors...

pls amend this script for me so that i just copy and paste and it works as i dont have much technical knowledge...

script is as below:

<form action="<?php echo $_server['php-self']; ?>" 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>
</form>
<?php
if(isset($_POST['submit'])){
if (isset ($_FILES['new_image'])){
$imagename = $_FILES['new_image']['name'];
$source = $_FILES['new_image']['tmp_name'];
$target = "user_images/".$imagename;
move_uploaded_file($source, $target);

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

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

$modwidth = 300; //large image size

$diff = $width / $modwidth;

$modheight = $height / $diff;
$tn = imagecreatetruecolor($modwidth, $modheight) ;
$image = imagecreatefromjpeg($file) ;

imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ;

imagejpeg($tn, $save, 100) ;

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

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

$modwidth = 150; //small thumbnail size

$diff = $width / $modwidth;

$modheight = $height / $diff;
$tn = imagecreatetruecolor($modwidth, $modheight) ;
$image = imagecreatefromjpeg($file) ;
imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ;

imagejpeg($tn, $save, 100) ;
echo "Large image: <img src='user_images/".$imagepath."'><br>";
echo "Thumbnail: <img src='user_images/sml_".$imagepath."'>";

}
}
?>

folder name in which images are upload is "user_images"

thanks.