1
我有一個窗體,實現字段上傳超過1個文件。但我仍然困惑如何將它存儲到MySQL。我只想將所有文件保存在MySQL中,只需提交一次。我需要你的幫助。如何在codeigniter中保存文件上傳的文件名
這是我的控制器:
function do_upload() {
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'jpeg|png|gif|jpg|txt|docs';
$config['max_size'] = '2000';
$config['max_width'] = '2000';
$config['max_height'] = '2000';
$this->load->library('upload', $config);
foreach ($_FILES as $key => $value) {
if (!empty($value['tmp_name'])) {
if (! $this->upload->do_upload($key)) {
$error = array('error' => $this->upload->display_errors());
} else {
}
}
}
}
,這是我的看法:
<?php echo form_open_multipart('upload/do_upload');?>
<input type="file" name="file1" />
<input type="file" name="file2"/>
<input type="file" name="file3"/>
</div>
<br /><br/>
<input type="submit" value="upload" name="upload" />
</form>