You are here: Re: [PHP] displaying image from blog « PHP « IT news, forums, messages
Re: [PHP] displaying image from blog

Posted by "Richard Lynch" on 10/08/05 00:32

On Tue, October 4, 2005 12:07 pm, blackwater dev wrote:
> I am querying a MSSQL db where an jpg image is stored as a blog.
>
> I have this code:
>
> <html>
> <head>
> <meta http-equiv="Content-Type" content="image/jpg">

I don't think you can use Content-type for this purpose...

Or, at least, I wouldn't expect browsers to be reliable in doing it.

It MIGHT be just case-sensitive to Content-type...

Rip out ALL the HTML code here, and do:

> </head>
> <body>
> <?
> //Do the query
> include_once("../includes.list.php");
> $ms_sql= new ms_db();
> $my_sql=new Database();
> $query="select photo from cars where id=22";
> $data=$ms_sql->query($query);
> while($obj = $ms_sql->objects('',$data)){

header("Content-type: image/jpg");

> echo $obj->photo;
> }
> $data=$ms_sql->disconnect();
> ?>
> </body>
> </html>
>
> But when viewed I just get all the junk code:
>
> !1AQaq"2B'¡±Á #3RðbrÑ
> $4á%ñ&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz‚ƒ„…â€
‡ˆ‰Å
'""•–—˜™š¢£¤¥¦§¨(c)ª²³´µ¶·¸¹ºÂÃÄÅÆÇÈÉÊÒÓÔÕÖ×ØÙÚâãäåæçèéêòóôõö÷øù
>
> What is wrong?

The browser is showing you the JPEG as "text"

If you had the actual JPEG, and you opened it in, like, Notepad or
whatever, that's what you would see.

--
Like Music?
http://l-i-e.com/artists.htm

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация