我想上传一个文件,并以标题名称替换它的名字,但我无法通过,即使没有在控制器回响在探查一个POST
获取文件名。上传文件,并显示其名称作为后
我还需要重命名,但在此之前,我需要知道的岗位价值,即文件名。
在这里,我张贴我的代码。
我的观点
<?php echo form_open_multipart('emailtemplate/do_upload');?>
<tr class='odd gradeX'>
<td class='center'>
<input type="file" name="userfile" size="20" />
</td>
<td class='center'>
<input placeholder='Title For Your File' name='title' class='form-control'>
<td class='center'>
<input placeholder='Comment On File' name='comment' class='form-control'>
</td>
</tr>
<input type="submit" value="upload" />
</form>
我的控制器
function do_upload()
{
$this->load->helper('form');
$this->load->helper('html');
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '1000';
$config['encrypt_name'] = true;
//$file=$this->input->post('userfile');
$this->load->library('upload', $config);
$this->upload->data();
$file_name = $this->upload->do_upload('userfile');
echo $file_name;
if (! $this->upload->do_upload())
{
$error = array('error' => $this->upload->display_errors());
$this->load->view('add/addfile', $error);
}
else
{
$data = array('upload_data' => $this->upload->data());
$this->load->view('add/addfile', $data);
}
$this->output->enable_profiler(true);
}
CI中访问后值通过'$这 - >输入 - >交的();'相同$ _POST –
如何重命名上传的文件? – amoeba