PHP L5 最简单的PHP上传案例


1.功能实现

前台: 静态  HTML页面

后台: 动态  PHP  页面

2.设计思路

3.多文件上传

附完整代码:
upload.html
[html]
<html>
<head>
<title>PHP上传文件表单</title>
</head>
<body>
<form enctype="multipart/form-data" action="upload.php" method="post">
<input type="hidden" name="max_file_size" value="1000000">
<center>请选择上传文件:
<input name="userfile" type="file">
<input type="submit" value="上传">
</center>
</form>
</body>
</html>
[/html]

upload.php
[php]
<?php
$uploaddir = ‘c:/’;
$uploadfile = $uploaddir.$_FILES[‘userfile’][‘name’];
print "<pre>";
if (move_uploaded_file($_FILES[‘userfile’][‘tmp_name’],$uploadfile))
{
print "上传成功!n";
print_r($_FILES);
}
else
{
print "上传失败!n";
print_r($_FILES);
}
?>
[/php]

1 Response Comment (1) Trackback (0)
  1. singlex Post author :

    在配置好PHP环境下,打开upload.html上传一个文件。注意上面upload.php里面设置的是上传到C盘根目录

发表评论