NYCPHP Meetup

NYPHP.org

[nycphp-talk] Force File Download HTTP Headers and IE Issue

Brian Pang bpang at bpang.com
Wed Sep 3 17:11:13 EDT 2003


oh yeah.. stupid Mac resource forks...

good point 

I don't have enough experience with them, but I would guess that there
is a way to append/pre-pend a resource fork to the file.
does anyone know about this?

or you could read the file's info or do the filename extension mapping
yourself in the script and set the content-type accordingly.




> >I think this has been addressed in the archives already..
> >but maybe not specific to PDF
> >
> >this works for me. Still prompts to save, but fills in the filename.
> >Does it work for you?
> >
> >
> >header("Cache-Control: no-cache, must-revalidate");
> >header("Pragma: no-cache");
> >header("Content-type: application/octet-stream");
> >header("Content-Disposition: attachment; filename=\"$filename\"");
> >$fd=fopen("$filePath","r");
> >fpassthru($fd);
> >
> 
> 
> It's worth pointing out, I suppose, that to some systems (i.e., 
> classic Mac OS), once you tell the browser that a JPEG (or PDF in 
> your case) is "application/octet-stream", it is no longer a JPEG (or 
> PDF).
> 
> If this is a controlled Windows environment which relies on simple 
> file extensions to identify files, you're probably fine, but if you 
> don't know the types of clients that might connect, you run a risk of 
> creating problems where people might double-click on the resulting 
> downloaded file and nothing happenes, because the OS no longer 
> recognizes it as a JPEG.
> 
> Cheers,
> -- 
> Marc Antony Vose
> http://www.suzerain.com/
> 
> Imagination is more important than knowledge.
> -- Albert Einstein
> _______________________________________________
> talk mailing list
> talk at lists.nyphp.org
> http://lists.nyphp.org/mailman/listinfo/talk
> 
> 






More information about the talk mailing list