如何设置多个提交按钮以上传

时间:2015-10-22 08:35:33

标签: php

我希望上传14条记录。在上传之前我想选择相应的检查按钮。一次只能上传一条记录。因此,所有14条记录都安排在一个带有两个按钮的表中,一个用于选择文件,另一个用于提交。但问题是只上传了第一个文件,其他文件没有上传。后来我知道我必须在所有提交中使用多个表格。怎么可能呢?

     <div class="portal-body" style="min-height: 268px;">                        
                <table class="table striped hover bordered" id="sample_editable_4">
                    <thead>
                        <tr>
                            <th id="eval_style">Sl No.</th>
                            <th id="eval_style">Document Name</th>  
                            <th id="eval_style">select</th>  
                            <th id="eval_style">Choose</th>
                            <th id="eval_style">Submit</th>
                        </tr>
                    </thead>
                    <tbody> 
                        <?php  $i=1; 
                            foreach($evidence_details->result() as $row_evidence) { ?>
                            <tr>   

                                <td><?php echo $i; ?></td>
                                <td><?php echo $row_evidence->evidence_name; ?> </td>            
                                <td>
                                    <input type="checkbox" name="evidences" id="<?php echo $row_evidence->evidence_id; ?>" value="<?php echo $row_evidence->evidence_id; ?>"  <?php if(in_array($row_evidence->evidence_id,$evidence)) { ?>checked="checked"<?php } ?> /> 

                                </td>
                                <td><input type="file" name="multiUpload" id="multiUpload" multiple /></td>
                                <td><button type="submit" class="btn blue" name="submitHandler" id="submitHandler" style="margin-top: 15px;margin-left: 54px;">Submit</button></td>                       

                            </tr> 
                            <?php $i++; }   ?> 
                    </tbody>
                </table> 
 </div>


<script type="text/javascript">
var config = {

    support : "image/jpg,image/png,image/bmp,image/jpeg,image/gif,application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,text/csv,application/pdf", 
 form: "demoFiler", // Form ID
 dragArea: "dragAndDropFiles", 
 uploadUrl: "<?php echo base_url(); ?>home/multiple_upload" 
 }
   $(document).ready(function()
  {
  initMultiUploader(config);
    });
  </script>

控制器

    function multiple_upload()
{    
  $application_id=$this->session->userdata('application_id');
  if(!is_dir('./application/assets/uploads/'.$application_id)) 
  {
    mkdir('./application/assets/uploads/'.$application_id, 0777, TRUE);

 }

if($_SERVER['REQUEST_METHOD'] == "POST"){
    if(move_uploaded_file($_FILES['file']['tmp_name'], "./application/assets/uploads/".$application_id."/".$_FILES['file']['name'])){
        echo($_POST['index']);
    }
    exit;
  }
}

   **multiupload.js**

 function initMultiUploader(){
new multiUploader(config);
  }

0 个答案:

没有答案