我在上传文件时遇到问题。我正在使用 codeigniter 框架和 dropzone.js 来上传文件。
在我看来:
<!-- START MODAL ADD FILE -->
<!-- Modal -->
<div class="modal fade" id="myModalFile" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="myModalLabel">Nahrát Soubory</h4>
</div>
<div class="modal-body">
<form action="<?php echo base_url("items/upload_agreement"); ?>" class="dropzone" method="POST" enctype="multipart/form-data">
<input type="hidden" name="agreement_dir_name" value="<?= $agreementDir;?>" >
<input type="hidden" name="dir_name" value="<?= $customer_dir;?>" >
<input type="hidden" name="customer_id" value="<?= $customerID;?>" >
<input type="hidden" name="agreement_id" value="<?= $agreementID;?>" >
<div class="fallback">
<input name="fileToUpload[]" type="file" id="fileToUpload" multiple />
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-danger btn-default" data-dismiss="modal">Zavřít</button>
<input type="submit" class="btn btn-success btn-default" value="Nahrát" >
</form>
</div>
</div>
</div>
</div>
<!-- END MODAL ADD FILE -->
控制器:
public function upload_agreement()
{
$customerDir = $this->input->post('dir_name');
$agreementDir = $this->input->post('agreement_dir_name');
$config['upload_path'] = "/www/Cesarlease2/leases/$customerDir/$agreementDir/";
$this->load->library('upload', $config);
$data = array('upload_data' => $this->upload->data());
$this->session->set_flashdata('success_msg', 'Soubor úspěšně nahrán');
redirect("items/items/".$this->input->post('customer_id')."/".$this->input->post('agreement_id'));
}
问题是上传的文件返回为空:
数组(1) { ["upload_data"]=> 数组(14) { ["file_name"]=> string(0) "" ["file_type"]=> string(0) "" ["file_path"]=> string(56) "/www/Cesarlease2/leases/testircrswqe789745asda/2-42017a/" ["full_path"]=> string(56) "/www/Cesarlease2/leases/testircrswqe789745asda/2-42017a/" ["raw_name"] => bool(false) ["orig_name"]=> string(0) "" ["client_name"]=> string(0) "" ["file_ext"]=> string(0) "" ["file_size"] => NULL ["is_image"]=> bool(false) ["image_width"]=> NULL ["image_height"]=> NULL ["image_type"]=> string(0) "" ["image_size_str"]=>字符串(0)“”}}
我尝试转储 fileToUpload 输入的 POST 值,也是空的。有什么我忽略的吗?