images from database do not display in chrome [SOLVED]

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mw007
Forum Newbie
Posts: 4
Joined: Wed Jan 19, 2011 11:58 am

images from database do not display in chrome [SOLVED]

Post by mw007 »

Hi All,

I am making a site where a user can upload and display images. This is straightforward enough in PHP. In fact, this works very well in firefox. Problem is with Chrome. The image appears while the image display page is loading, but as soon as loading is done, the image error icon appears. Has anyone else experienced this with Chrome?

Ideas to try and fix this? Again, it works well in firefox. The display image code is below.

Code: Select all

<?php
require_once('Comic.php');

if (isset($_REQUEST['id'])) {
	$comic = Comic::GetById($_REQUEST['id']);

	header("Content-length: {$comic->imageSize}");
	header("Content-type: {$comic->imageType}");
	echo $comic->image;
	exit;
}

Last edited by mw007 on Wed Jan 19, 2011 1:40 pm, edited 1 time in total.
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: images from database do not display in chrome

Post by Jonah Bron »

I know this doesn't answer your question, but the filesystem is much better suited for storing images. As to your question though, it sounds like there's some sort of data at the end that's (not?) getting out, corrupting the image.
mw007
Forum Newbie
Posts: 4
Joined: Wed Jan 19, 2011 11:58 am

Re: images from database do not display in chrome

Post by mw007 »

Jonah Bron wrote:I know this doesn't answer your question, but the filesystem is much better suited for storing images. As to your question though, it sounds like there's some sort of data at the end that's (not?) getting out, corrupting the image.
That's possible. But I think you're right about the filesystem being better for storing images, so I'll go that route. I've just always liked having them in a database so I don't have to deal with permissions 8)

Thanks for the quick reply!
Post Reply