Re: Re: downloading an image

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, April 11, 2007 9:37 am, Ross wrote:
> yes it is image/jpeg

Some (ancient) versions of IE don't give a doodly-squat what your
Content-type header is.  They'll "guess" based on the URL.

Your URL is like this:
download.php?id=47

IE thinks that's a .php file, and has no idea how to handle a .php file.

Some (ancient) versions of IE won't accept a GET arg on images.  Or
maybe it was .pdf  Or maybe it was .fdf  Or maybe it was... I forget. 
All I know is, I gave up on the browser doing the right thing with
content-type header, and always make my URL indistinguishable from a
perfectly valid "static" URL to an image, even if the image is not, in
fact, static.

That's pretty much part of what I ranted about here, oh so long ago:
http://richardlynch.blogspot.com/


In other potential problems, just off the top of my head...

HOw many bytes can content field hold in DB?
How many bytes can query buffer accept?
What is actually *IN* content field?
Did you manage to insert it correctly?
How do you know?
.
.
.


There are a dozen ways for this to "go wrong" once you start cramming
images into your DB.

If you can anticipate all those, and plan/code/design around them, fine.

But that doesn't make it a Good Idea to cram images in DBs unless you
know what you are doing, and have a very good reason to do so.

The preceding statment will almost for sure cause yet another flame
war just like in the archives, but there it is.

> "Roberto Mansfield" <robertom@xxxxxxxxxxxxx> wrote in message
> news:6C.45.18117.1A1FC164@xxxxxxxxxxxxxxx
>> Verify that your $type is a correct mime type.
>>
>>
>> Ross wrote:
>>> tthe image does not display although it exists in the table
>>> 'images'
>>>
>>>
>>> This calls the download script
>>>
>>>
>>> <?
>>>  $property_id = $_SESSION['property_id'] ;
>>>  $query = "SELECT * FROM images WHERE property_id='$property_id'";
>>> $result = mysql_query($query);
>>> while($row = mysql_fetch_array($result, MYSQL_ASSOC))
>>> {
>>>
>>> echo $id= $row['id'];
>>> echo $title= $row['title'];
>>> $link = "download.php?id=$id";
>>> }
>>> ?>
>>> <img src="<?php echo $link; ?>"/>
>>>
>>>
>>>
>>> this is the download script
>>>
>>> id = $_GET['id'];
>>> $query = "SELECT name, type, size, content FROM images WHERE id
>>> ='$id'";
>>>
>>>  $result = mysql_query($query) or die(mysql_error());
>>> list($name, $type, $size, $content) = mysql_fetch_array($result);
>>>
>>> header("Content-length: $size");
>>> header("Content-type: $type");
>>>
>>> echo $content;
>>>
>>> exit;
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux