![](https://images2015.cnblogs.com/blog/848574/201603/848574-20160309222314054-2120922254.jpg)
![](https://images2015.cnblogs.com/blog/848574/201603/848574-20160309222320241-909701212.jpg)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>
<body>
<form action="chuli.php" method="post" enctype="multipart/form-data">
<input type="file" name="file" />
<input type="submit" value="上传"/>
</form>
<a href="../DotNET课程大纲.xlsx">下载文件</a>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>
<body>
<?php
/*echo $_FILES["file"]["name"]."<br>";
echo $_FILES["file"]["type"]."<br>";
echo $_FILES["file"]["size"]."<br>";
echo $_FILES["file"]["tmp_name"]."<br>";
echo $_FILES["file"]["error"];*/
//1.判断是否出错
if($_FILES["file"]["error"])
{
echo "文件上传出错!";
}
else
{
//2.加限制条件
if(($_FILES["file"]["type"]=="image/jpeg" || $_FILES["file"]["type"]=="image/jpg") && $_FILES["file"]["size"]<=102400)
{
//3.造一个文件的存储路径
$str = date("YmdHisms",time());
$filename = "./images/".$str.$_FILES["file"]["name"];
//4.判断文件是否存在
if(file_exists($filename))
{
echo "该文件已经存在!";
}
else
{
//5.移动文件
move_uploaded_file($_FILES["file"]["tmp_name"],iconv("UTF-8","gb2312",$filename));
echo "该文件成功上传,保存在了:".$filename;
echo "<div style='height:300px;300px'><img src=$filename /></div>";
}
}
else
{
echo "文件不符合要求!";
}
}
?>
</body>
</html>