出於安全原因,我在MYSQL中存儲了一些圖片。當我下載圖像時,文件將以正確的文件大小和名稱下載,但不會顯示圖像。當我看着它的屬性時,圖像也沒有尺寸。我正在使用cakephp。下載時沒有尺寸的Mysql blob圖片
header("Content-type: ".$file['UploadFile']['file_extension']);
header("Content-Disposition: attachment; filename=\"".$file['UploadFile']['file_name']."\"");
header("Content-length: ".$file['UploadFile']['file_size']);
echo $file['UploadFile']['file_content'];
保存我的形象用下面的代碼...
public function image_upload($fileName, $source, $extension, $file_size) {
$this->loadModel('UploadFile');
$content = addslashes(file_get_contents($source));
$file_data = array('UploadFile' => array('title' => $fileName, 'file_content' => $content, 'file_name' => $fileName, 'file_extension' => $extension, 'file_size' => $file_size, 'file_type' => 'image-art'));
$this->UploadFile->create();
$this->UploadFile->save($file_data);
$file_id = $this->UploadFile->id;
return $file_id;
}
打印'$文件[ 'UploadFile'] ['file_extension']'out,它返回什麼? – Dion 2012-04-10 21:16:13
你的問題提出了兩個不同的概念 - 從數據庫中提取圖像 - 並從文件上傳中拉取圖像。你在說什麼? – Xeoncross 2012-04-10 21:26:54
對不起,我在mysql中的表名是upload_files,所以對於cakephp你訪問數組中的數據與模型UploadFile – 2012-04-10 23:28:39