client15.html
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>上传文件</title>
</head>
<body>
<!--enctype="multipart/form-data",以2进制传递数据-->
<form action="server15.php" method="post" enctype="multipart/form-data">
<input type="file" name="file"><br/>
<input type="submit" value="提交">
</form>
</body>
</html>
server15.php<span style="font-size:18px;"><!DOCTYPE html>
<!--//上传文件-->
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
</head>
<body>
<?php
/**
* Created by PhpStorm.
* User: zsgjs038
* Date: 2015/9/2
* Time: 11:17
*/
//传的所有文件都会存放到$_FILES数组中
//print_r($_FILES);
//数组打印出来如下:
//Array
//(
// [file] => Array
//(
// [name] => mn01.jpg
// [type] => image/jpeg
// [tmp_name] => E:\h5tools\install\tmp\php825C.tmp
// [error] => 0
// [size] => 33254
// )
//
//)
//获取文件
$file= $_FILES['file'];
//把文件移到当前目录:
//获取文件名字
$fileName=$file['name'];
move_uploaded_file($file['tmp_name'],$fileName);
echo "<img src='$fileName'>";
?>
</body>
</html>
</span>
源码下载:
http://download.csdn.net/detail/zhaihaohao1/9079123