I am attempting to download files (usually images) for viewing with
either the user's browser or a program associated with the file type.
Unfortunately, this requires that it works in MSIE (works ok with
Mozilla and Opera) but when I attempt to use MSIE it offers a choice
of either opening it or saving.

Opening the message, causes the image viewing program to state that
the file is not a valid jpeg (I'm using jpegs for testing presently).
And when I select "Save", nothing is downloaded.

I'm already losing my hair, so please save the hair!

The afflected code:

header("Content-type: " .
header("Content-length: " . $row['size']);
attachment;filename=" . $row['filename']);
header("Pragma: no-cache");
header("Expires: 0");
$fa = fopen("/tmp/attach/" . $row['id'],"rb");
$buffer = fread ($fa, $row['size']);
echo $buffer;

I've also tried:

$fa = fopen("/tmp/attach/" . $row['id'],"rb");
echo fread ($fa, $row['size']);
or die("Unable to read file!");


This is the final test of a gentleman: His respect for
those who can be of no possible service to him.

--William Lyon Phelps, American educator (1865-1943).
Design West
Chief Technology Officer
ACM Member
Computer Society Member
Usenix & SAGE