0
我有以下情况: 当用户单击时,我需要一次上传3个文件。还有的代码,我有我的观点:将上传的文件数据存储到数组中
<?php echo form_open_multipart('uploads/do_upload', 'class="dropzone", id="dropzone-prod", data-nextFormExecDropzone="#dropzone-promo"');?>
<div class="fallback">
<input type="file" name="userfile" size="20" />
</div>
</form>
<?php echo form_open_multipart('uploads/do_upload', 'class="dropzone", id="dropzone-promo", data-nextFormExecDropzone="#dropzone-plan"');?>
<div class="fallback">
<input type="file" name="userfile" size="20" />
</div>
</form>
<?php echo form_open_multipart('uploads/do_upload', 'class="dropzone", id="dropzone-plan"');?>
<div class="fallback">
<input type="file" name="userfile" size="20" />
</div>
</form>
<div class="col-lg-4">
<button id="processQueue" class="btn btn-primary" type="button"><i class="fa fa-upload"></i>Start Upload</button>
</div>
当用户点击该按钮时,我有向各自形成我希望它的顺序JavaScript代码。 在我的控制,我有以下方法(do_upload()):
function do_upload() {
//$filePath = $this->config->item('base_current_upload_url');
$filePath = APPPATH.'UPLOADS/';
$filePathAfterUploaded = $this->config->item('base_uploaded_url');
$config['upload_path'] = $filePath;
$config['allowed_types'] = '*';
$config['max_size'] = 1024 * 100;
$this->load->library('upload', $config);
//$this->load->library('csvreader');
//$filePathAfterUploaded = $this->config->item('base_uploaded_url');
//print_r($filePath); die();
$basefilepath = APPPATH.'UPLOADS/';
$this->load->model('uploads_m');
if (! $this->upload->do_upload('file')) {
$error = array('error' => $this->upload->display_errors());
print_r($error);
}
else {
$data = array('upload_data' => $this->upload->data());
print_r($data); die();
}
}
问题:
我需要上传3个文件。如果只有一个失踪,我不能继续。 我这样做,函数do_upload被称为每个文件的上传过程中,所以我需要找到一种方法来确定3个文件上传。 (之后,我将使用mysql'load data infile'将这些文件中的数据加载到某些表中,但是如果这三个文件已上传,我只能这样做。 您能帮我找到一种方法来处理这种情况吗?
的$数据每次do_uplaod被称为的结构是这样的:
Array
(
[upload_data] => Array
(
[file_name] => PROMOWEB111120131.txt
[file_type] => text/plain
[file_path] => C:/Program Files/EasyPHP-DevServer-13.1VC9/data/localweb/projects/integration/www/application/UPLOADS/
[full_path] => C:/Program Files/EasyPHP-DevServer-13.1VC9/data/localweb/projects/integration/www/application/UPLOADS/PROMOWEB111120131.txt
[raw_name] => PROMOWEB111120131
[orig_name] => PROMOWEB11112013.txt
[client_name] => PROMOWEB11112013.txt
[file_ext] => .txt
[file_size] => 2.67
[is_image] =>
[image_width] =>
[image_height] =>
[image_type] =>
[image_size_str] =>
)
)
但我怎么会在这个do_mysql_load_data_infile中标识文件的名称? – Periback
看到我上面的例子。而不是只存储计数,将数据存储在数组中并检查数组的长度。 –
谢谢米勒! :D – Periback