All pastes #895141 Raw Edit

Andy

public php v1 · immutable
·published 2008-02-07 16:30 UTC
rendered paste body
<?PHP/*$target - Intended to be grabbing from a POST form from a <input type="file" name="target" />$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 '<br />'. $ext[1]	echo '<br />'. 	$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 '<br />WARNING: File type must be .png, .jpeg, .jpg or .gif!<br />';	}	}?>