Image

Imagesimonmarshall wrote in Imagephp

Listens: Robbie Williams - Mr Bojangles

Hi folks. Just a little stuck, would appreciate some help.

I'm using a script (viewfile.php) to load some files from outside of root, just some basic file upload protection.

I can get the image to download file, but the problem comes when I try to view a jpg using the script. Firefox works, but in IE6 or 7 it prompts me to download viewfile.php. If I do and rename it it's my jpg, but I'd rather it just opens live in the page.

What I'm trying to use is:

header("Content-Type: image/jpg");
readfile($uploadDir.$theFile);

which as I say, works in firefox so the path is fine and it finds the image ok. When I try to get at it directly I get a prompt. If I call viewfile.php as the src of an image it works, but that just confuses me more.

I've tried all types of headers, content-disposition, cache expiration and so on. I reckon it's something simple, since every bloody page on the web helps me force the downloads, but doesn't tell me how to force NOT downloading, if you get me.

Suggestions most greatfully appreciated.

Cheers,
Si