index.php
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>test22</title>
</head>
<body>
<form action="serve.php" method="post" enctype="multipart/form-data">
<input type="file" name="file" ><br/>
<input type="text" name="123" value="123"><br/>
<input type="submittton" value="上传">
</form>
</scr
</body>
</html>
serve.php
<?php
if($_FILES['file']['type']!="image/jpeg"&&$_FILES['file']['type']!="image/pjepg")
{
echo "检查";
}
else
{
$file=$_FILES['file']['tmp_name'];
$rand=md5(date(YmdHis).rand(0,1000));
mkdir("upload/".$rand,0777,TRUE);
move_uploaded_file($file,"upload/".$rand."/".$_FILES['file']['name']);
//move_uploaded_file($file,"upload/".$rand."/".$_FILES['file']['tmp_name']);
echo "文件真实地址:http://test1.iw3c.work/filecos"."/upload/".$rand."/".$_FILES['file']['name'];
}
/*print_r($_POST);
echo $_FILES['file']['name']."<br/>";
echo $_FILES['file']['type']."<br/>";
echo $_FILES['file']['size']."<br/>";
echo $_FILES['file']['tmp_name']."<br/>";*/
?>
<img src="http://test1.iw3c.work/filecos<?php echo "/upload/".$rand."/".$_FILES['file']['name']?>">