hi:
i have this script (found in this forum) i've used to force
pdf files
downloading w/o problems
now i want to use it for images (jpg), so i changed
$ctype="application/pdf";
to
$ctype="image/jpg";
the images d/l but when i try to open them i receive error
messages:
Preview: Couldn't open the file. It may be corrupt or a file
format that
Preview doen't recognize
Photoshop: The file can't be opened because the segment
marker is too
short (probably the file is incompleted)
any ideas?
tia,
jdoe
> <?php
> $filenum = $_GET['file'];
>
> switch($filenum) {
> case '0': $filename="media/...."; break;
> case '1': $filename="media/...."; break;
> }
>
> // required for IE, otherwise Content-disposition is
ignored
> if(ini_get('zlib.output_compression'))
> ini_set('zlib.output_compression', 'Off');
>
> // addition by Jorg Weske
> $file_extension =
strtolower(substr(strrchr($filename,"."),1));
>
> $ctype="application/pdf";
> header("Pragma: public"); // required
> header("Expires: 0");
> header("Cache-Control: must-revalidate, post-check=0,
pre-check=0");
> header("Cache-Control: private",false); // required for
certain browsers
> header("Content-Type: $ctype");
> // change, added quotes to allow spaces in filenames, by
Rajkumar Singh
> header( "Content-Description: File Transfer");
> header("Content-Disposition: attachment;
filename=\"".basename($filename)."\";" );
> header("Content-Transfer-Encoding: binary");
> header("Content-Length: ".filesize($filename));
> readfile("$filename");
> exit();
> ?>