上传多个文件

 <label>请选择要上传的文件</label>
<form name="form1" method="post" enctype="multipart/form-data">
    <table id="up_table" border=1 bgcolor="aqua">
        <tr id="auto">
            <td>上传文件:</td>
            <td><input type="file" name="u_file[]" /></td>
            <td><input type="button" name="del" value="删除" onclick="delRow(this)" id="del" /></td>
            <td><input type="button" name="add" value="增加" onclick="insertRowl(this)" id="add" /></td>
        </tr>
        <tr>
            <td>上传文件:</td>
            <td><input type="file" name="u_file[]" /></td>
            <td><input type="button" name="del" value="删除" onclick="delRow(this)" id="del" /></td>
            <td><input type="button" name="add" value="增加" onclick="insertRowl(this)" id="add" /></td>
        </tr>
        <tr><td colspan="4"><input type="hidden" name="action" value="m_upload" /><input type="submit" value="上传" /></td></tr>
    </table>
</form>
<script language="javascript">
    function insertRowl() {
        var obj=document.getElementsByName("show")[0].cloneNode(true);
        document.all("auto").appendChild(obj);
    }
    function delRow(obj) {
        var rowIndex=document.all("up_table").rows.length;
        if(rowIndex>3){
            obj.parentNode.parentNode.removeNode(true);
        }
    }
</script>
<?php
    if($_POST[action]=="m_upload"){
        $file_path="./uploads//";
        $filename=$_FILES[u_file][name];
        $tmpname=$_FILES[u_file][tmp_name];
        for($i=0;$i<count($filename);$i++){
            move_uploaded_file($tmpname[$i],$file_path.$i.$filename[$i]);
        }
        echo "文件上传成功";
    }
?>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值