On 21/05/12 11:42, teji infin wrote:
Actually i am storing my images in my mysql database using image
longblob named entry..
On Mon, May 21, 2012 at 4:07 PM, LITTO CHACKO <[email protected]
<mailto:[email protected]>> wrote:
if u stored your image in webroot folder u can display images
rightly. but if u uploaded images out of webroot folder then u
have to use some imagecontroller to set path:-
like this:-
?php
class ImagepathController extends AppController{
function index(){
$query=$this->params->query;
$file = $query['file'];
$width = $query['width'];
$height = $query['height'];
$base = Configure::read('MediaDir').'projects/';
$filePath = $base.$file;
if(file_exists($filePath)){
list($imwidth,$imheight,$type, $attr) =
getimagesize($filePath);
if($imwidth>=$imheight){
$per = $imwidth/$width;
$cwidth = $imwidth/$per;
$cheight = $imheight/$per;
}else{
$per = $imheight/$height;
$cheight = $imheight/$per;
$cwidth = $imwidth/$per;
}
if($imwidth<=$width && $imheight<=$height){
$cwidth=$imwidth;
$cheight=$imheight;
}
$extt = explode('.',strtolower($file));
$ext = $extt[count($extt)-1];
ob_start();
if($ext=='jpeg' || $ext=='jpg'){
header('Content-type: image/jpeg');
$im=imagecreatefromjpeg($filePath);
$dest = imagecreatetruecolor($cwidth,$cheight);
imagecopyresized($dest,$im,0,0,0,0,$cwidth,$cheight,$imwidth,$imheight);
imagejpeg($dest);
}
if($ext=='png'){
header('Content-type: image/png');
$im=imagecreatefrompng($filePath);
$dest = imagecreatetruecolor($cwidth,$cheight);
imagecopyresized($dest,$im,0,0,0,0,$cwidth,$cheight,$imwidth,$imheight);
imagepng($dest);
}
if($ext=='gif'){
header('Content-type: image/gif');
$im=imagecreatefromgif($filePath);
$dest = imagecreatetruecolor($cwidth,$cheight);
imagecopyresized($dest,$im,0,0,0,0,$cwidth,$cheight,$imwidth,$imheight);
imagegif($dest);
}
exit();
}else{
ob_clean();
ob_start();
header('Content-type: image/jpeg');
$dest = imagecreatetruecolor(300,300);
imagejpeg($dest);
exit();
}
}
}
?>
On Mon, May 21, 2012 at 4:04 PM, Teji <[email protected]
<mailto:[email protected]>> wrote:
Can anyone tell me how to display images from my database to my
webpage.
i upload the images in database using longblob datatype.
anyone help plz..
--
Our newest site for the community: CakePHP Video Tutorials
http://tv.cakephp.org
Check out the new CakePHP Questions site
http://ask.cakephp.org and help others with their CakePHP
related questions.
To unsubscribe from this group, send email to
[email protected]
<mailto:cake-php%[email protected]> For more
options, visit this group at
http://groups.google.com/group/cake-php
--
Litto Chacko
Axtec Softwares
--
Our newest site for the community: CakePHP Video Tutorials
http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org
and help others with their CakePHP related questions.
To unsubscribe from this group, send email to
[email protected]
<mailto:cake-php%[email protected]> For more options,
visit this group at http://groups.google.com/group/cake-php
--
Our newest site for the community: CakePHP Video Tutorials
http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and
help others with their CakePHP related questions.
To unsubscribe from this group, send email to
[email protected] For more options, visit this
group at http://groups.google.com/group/cake-php
Assuming you wish to display the images on a web page, you would need to
extract the image from the database and write it to disk as a jpeg,gif
or png image. The web page can then display it through an img tag.
Alternatively with HTML5, you could try extracting the image and
displaying it in a canvas element which would be a fun project.
This might be of interest:
http://bakery.cakephp.org/articles/grzegorzpawlik/2009/03/04/imagebehavior-best-from-database-blobs-and-file-storage
--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at
http://groups.google.com/group/cake-php