§也只是进行了循环上传而已,当然你也
可以使用
§!
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script language="javascript" type="text/javascript">
function AddInput(){
var input=document.createElement('input');//创建一个 input 节点
var br=document.createElement('br');//创建一个 br 节点
input.setAttribute('type','file');//设置 input 节点 type 属性为 file
input.setAttribute('name','files[]');//设置 input 节点 name 属性为 files[]
,以 数
组的方式传递给服务器端
document.myForm.appendChild(br);//把节点添加到 form1 表单中
document.myForm.appendChild(input);
}
</script>
</head>
<body>
<?php
/*
* 可同时处理用户多个上传文件。效验文件有效性后存储至指定目录。
* 可返回上传文件的相关有用信息供其它程序使用。(如文件名、类型、大小、保存路径)
*/
class UploadFile {
protected $user_post_file = array(); //用户上传的文件
protected $save_file_path; //存放用户上传文件的路径
protected $max_file_size; //文件最大尺寸
protected $last_error; //记录最后一次出错信息
//默认允许用户上传的文件类型
protected $allow_type = array('gif', 'jpg', 'png', 'zip', 'rar', 'txt', 'doc',
'pdf','docx');
protected $final_file_path; //最终保存的文件名
protected $save_info = array(); //返回一组有用信息,用于提示用户。
/**
* 构造函数
*/