$name - What you want the file to be called when saved. $dir - Where you want the file to be saved. */ function upload($target, $name, $dir) { $ext = split('/',$_FILES[$target]['type']); echo '
'. $ext[1] echo '
'. $upload = $dir . $name .'.'. $ext[1]; $uploadtype = $_FILES[$target]['type']; $types = array("image/jpeg", "image/jpg", "image/png", "image/gif"); if (in_array($uploadtype, $types)) { move_uploaded_file($_FILES[$target]['tmp_name'], $upload) or die('Your file was not uploaded correctly, Please try again!'); } else { echo '
WARNING: File type must be .png, .jpeg, .jpg or .gif!
'; } } ?>