Blogger Information
Blog 39
fans 1
comment 0
visits 62394
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
多文件上传,获取上传的文件的数据
Dai的博客
Original
1500 people have browsed it

一般我们获取多个文件上传的数据的时候,我们需要进行数据的获取下面直接贴上代码:

<form name="" id="upfile" enctype="multipart/form-data">
   <input type="file" name="dimission_apply" id="dimission_apply" class="inputFile ">
   <input type="file" name="dimission_assoc" id="dimission_assoc" class="inputFile ">
   <input type="file" name="dimission_work_assoc" id="dimission_work_assoc" class="inputFile ">
  <input type="file" name="dimission_consumable" id="dimission_consumable" class="inputFile ">
  <div class="btn btn-success text-center" onclick="upfile({$perFlowId});">提交上传文件</div>
</form>
<script>
    function upfile(id) {
    var formData = new FormData();
    $sign ="1";
    if ($("#dimission_report").val() == ''){
        $sign = "2";alert('请上传辞职报告!');
    }else if ($("#dimission_apply").val() == ''){
        $sign = "2";alert('请上传员工离职申请表!');
    }else if ($("#dimission_assoc").val() == ''){
        $sign = "2";alert('请上传离职交接表!');
    }else if ($("#dimission_work_assoc").val() == ''){
        $sign = "2";alert('请上传离职人员工作交接表!');
    }else if ($("#dimission_consumable").val() == ''){
        $sign = "2";alert('请上传工具耗材交接表!');
    }else{
        formData.append("dimission_report",$("#dimission_report")[0].files[0]);
        formData.append("dimission_apply",$("#dimission_apply")[0].files[0]);
        formData.append("dimission_assoc",$("#dimission_assoc")[0].files[0]);
        formData.append("dimission_work_assoc",$("#dimission_work_assoc")[0].files[0]);
        formData.append("dimission_consumable",$("#dimission_consumable")[0].files[0]);
    }
    if ($sign == '1') {
        $.ajax({
            type:'post',
            data:formData,
            cache: false,
            processData: false,
            contentType: false,
            async: false,
            url:'/index.php/Home/dimission/personal_data_upfile.html?id='+id+'&type=dimission',
            success:function (data) {
                if (data == '1'){
                    alert('上传成功');
                }else if(data == '2'){
                    alert('上传失败');
                }else{
                    alert(data);
                }
            }
        })
    }
</script>


Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post