面对与浏览器chache相关的问题.
function doUpload(){
$data['includeView'] = "profileconfirm";
$config['upload_path'] = './img/images/uploaded/';
$config['allowed_types'] = 'gif|jpg|png|jpeg';
$config['max_size'] = '5000';
$config['max_width'] = '1024';
$config['max_height'] = '768';
$config['file_ext'] =".jpeg";
$config['file_name'] = $profileId.$config['file_ext'];
$config['overwrite'] = TRUE;
$this->load->library('upload', $config);
$query = null ;
if ( ! $this->upload->do_upload()){
// Error here
}else{
// Image uploaded sucess fully
// $profile - business logic to populate $profile
$data['PROFILE_DETAILS'] = $profile;
$this->load->view('index', $data);
}
Run Code Online (Sandbox Code Playgroud)
此方法用于图像上传.成功上传图像后,它会加载索引视图页面,该页面内部包含profileconfirm视图页面.
但在profileconfirm页面上,新上传的图片不会反映出来.有时它工作正常,但有时候没有,这种情况大多数时候都会发生.
请帮忙
Fra*_*ita 13
您可以向客户端发送正确的标头以禁用缓存:
....
$this->output->set_header("HTTP/1.0 200 OK");
$this->output->set_header("HTTP/1.1 200 OK");
$this->output->set_header('Last-Modified: '.gmdate('D, d M Y H:i:s', $last_update).' GMT');
$this->output->set_header("Cache-Control: no-store, no-cache, must-revalidate");
$this->output->set_header("Cache-Control: post-check=0, pre-check=0");
$this->output->set_header("Pragma: no-cache");
$this->load->view('index', $data);
Run Code Online (Sandbox Code Playgroud)
注意:输出类自动初始化