|
$config['upload_path'] = FCPATH.'static\upload';
$config['allowed_types'] = 'gif|jpg|png';
$config['file_name'] = date("ymdhis");
$this->load->library('upload', $config);
if ( ! $this->upload->do_upload('bannerFile'))
{
$error = array('error' => $this->upload->display_errors());
var_dump($error);
}
else
{
echo "------------";
}
view:
<form action="<?php echo base_url('Banner/addBannerAction');?>" class="form-horizontal" enctype="multipart/form-data" method="post">
<div class="form-group">
<label for="file" class="col-sm-2 control-label">上传图片</label>
<div class="col-sm-10">
<input id="file" class="form-control" name="bannerFile" type="file" />
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-default">添加</button>
</div>
</div>
</form> |
|