Re: FN-FORUM: PHP Download script
date posted 16th January 2008 07:34
Steve,
> Steven Lavine wrote:
> >
> > Hi Guys,
> >
> > I hope you all had a great christmas and new year.
> > I'm having a slight problem with a PHP download script that I am
> > helping a client with.
> > When an image file is downloaded, it is corrupted. All other files
> are
> > fine, it is just image files. The client has a large number of jpeg
> > files that they charge customers for, so jpegs cannot be corrupted.
> > Any ideas, as I'm stumped. Here is a snippet of code that dowloads
> the
> > file.
> >
> > header("Content-Transfer-Encoding: Binary");
> > header('Content-Type: application/octet-stream;
> > name="'.basename($filename).'"');
> > header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
> > $date = date("D, d M Y H:i:s T");
> > header("Last-Modified: $date");
> > header("Expires: 0");
> > header("Accept-Ranges: bytes");
> > header("Content-Length: ".filesize($filename));
> > header('Content-Disposition: attachment;
> > filename="'.basename($filename).'"');
> > header("Content-Description: File Transfer");
> >
> >
> > Best Regards,
> >
> > Steven
> >
> Thanks every one who has helped. None of the above has worked, I've
> tried setting the content-type to jpeg, using the mime type as the same
> script is run if it is a jpeg, png, pdf, mp3 etc, everything other than
> an image works perfectly though.
>
> Steve
>
I was a little puzzled why you wanted to do this at all with single
image files.
Could you not just embed the links to the jpegs in a web page and leave
it to the web server to negotiate the content types and the user to
download them if she wished?
Graham
--
Graham Stark, Virtual Worlds, http://www.virtual-worlds.biz
Phone (+44) 01908 618239 Mobile (+44) 07952633185 Skype graham_k_stark