I am storing a few images in MYSQL for security reasons. When I download the image the file downloads with the correct file size and name but no image is displayed. Also the image has no dimensions when I look at it's properties. I am using cakephp.
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'];
I save my image with the following code...
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;
}