我想隐藏用户的图片url,所以我使用php header()
函数, Bluehost上的网站,它在localhost上运行良好。 这里是我的功能来访问图像。PHP header('Content-Type:image/jpeg')在localhost上运行,但不能在真实服务器上运行
function download($name = '', $tiny = '0') {
if ($name != '') {
$file = $this->mdl->get_file($name);
if($file){
$mime = mime_content_type('./'.$file->path.$file->name);
header('Content-Type: '.$mime);
echo file_get_contents('./'.$file->path.$file->name);
}
}
}
这里是模型get_file功能:
function get_file($name=''){
if($name!=''){
return $this->db->select('*')
->from('docs')
->where('name',$name)
->get()
->row();
}
return false;
}
任何有益的答案是appretiated。
bluehost发生了什么?任何类型的错误? –
当我想使用Mozilla查看图像时出现以下错误:图像“http://www.mywebsitename.com/index.php/main/download/1234556.jpg”无法显示,因为它包含错误。但是当我使用Chrom浏览器时,它只显示一个小框而不是图像。 @Gabriel Heming – Aziz