Re: [PHP] Re: downloading an image

2007-04-11 Thread Richard Lynch
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" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
>> 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";
>>> }
>>> ?>
>>> 
>>>
>>>
>>>
>>> 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



[PHP] Re: downloading an image

2007-04-11 Thread Ross
yes it is image/jpeg


"Roberto Mansfield" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> 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";
>> }
>> ?>
>> 
>>
>>
>>
>> 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



[PHP] Re: downloading an image

2007-04-11 Thread Roberto Mansfield
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";
> }
> ?>
> 
> 
> 
> 
> 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