PHP实现文件上传很简单,代码如下:
//**************up.php
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>Tansf</title>
</head>
<body>
<form name="form1" enctype="multipart/form-data" method="post" action="updo.php">
<input name="userfile" type="file" id="userfile">
<input type="submit" name="Submit" value="提交">
</form>
</body>
</html>
//**************updo.php
<?php
if (is_uploaded_file($_FILES['userfile']['tmp_name']))
{
copy($_FILES['userfile']['tmp_name'], $_FILES['userfile']['name']);
echo "success";
}
else
{
echo "文件上传失败";
}
?>
以上代码会把文件上传到 updo.php 所在的目录,如果在Linux下,要确保web服务器有访问该目录的权限.
本文地址:http://com.8s8s.com/it/it26221.htm