当前位置:Gxlcms > PHP教程 > php下传图片

php下传图片

时间:2021-07-01 10:21:17 帮助过:26人阅读

php上传图片
";
	if (!is_uploaded_file($_FILES["upfile"][tmp_name]))
		//是否存在文件
		{
		echo "";
		echo "";
		exit;
	}
	$file = $_FILES["upfile"];
	if ($max_file_size < $file["size"])
		//检查文件大小
		{
		echo "";
		echo "";
		exit;
	}
	if (!in_array($file["type"], $uptypes))
		//检查文件类型
		{
		$message = "文件类型不符!".$file["type"];
		echo "";
		echo "";
		exit;
	}
	if (!file_exists($destination_folder)) {
		mkdir($destination_folder);
	}
	$filename = $file["tmp_name"];
	$image_size = getimagesize($filename);
	$pinfo = pathinfo($file["name"]);
	$ftype = $pinfo['extension'];
	$destination = $destination_folder . time() . "." . $ftype;
	if (file_exists($destination) && $overwrite != true) {
		echo "";
		echo "";
		exit;
	}
	if (!move_uploaded_file($filename, $destination)) {
		echo "";
		echo "";
		exit;
	}
	$pinfo = pathinfo($destination);
	$fname = $pinfo[basename];
}
?>

?

人气教程排行