1,前端表单
2,后台接收图片
1,前端表单
<?php echo form_open_multipart('upload/do_upload');?>
<input type="file" name="userfile" size="20" />
<br />
<input type="submit" value="upload" />
</form>
2,后台接收图片
public function do_upload()
{
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = 100;
$config['max_width'] = 2000;
$config['max_height'] = 2000;
$config['file_name'] = time();
$this->load->library('upload', $config);
if ( ! $this->upload->do_upload('userfile'))
{
echo $this->upload->display_errors();
}
else
{
echo "成功!";
}
}