Richard Lynch responded Monday, August 26, 2002 3:28 PM to Roger Lewis >I'm not certain this is the right place to ask, but here goes. For security > >reasons I have placed certain document files in a directory outside my web > >root. There are many types of files included (e.g. jpg, gif, txt, pdf, xls, > >doc, mdb, ppt, and dwg). Clicking links on my web page will download the > >files through a php script (getdocfile.php) into a new pop-up window. The > >following is how I have coded the link: > > > ><a href='#' target="_blank" > >onclick="window.open('../getdocfile.php?file=<?php echo > >$DrawingGroups->Value("filename")?>', > >'_blank','resizable=yes,scrollbars=yes,width=700,height=500');return > >false"><?php echo $DrawingGroups->Value("is_viewable")?></a> > > > > > >Problem: The download fails with IE5.5 when trying to retrieve files other > >than jpg, gif, txt, and pdf. One of the following happens depending on > >whether or not I force the download dialog box for the file to appear: > >(Note: I force the download dialog by commenting out the appropriate mime > >types in the code below) > > IE is stupid. > > Really, really stupid. > > Not that Netscape is any smarter, or anything, but IE is really really > really stupid. > > In particular, their hack to have embedded documents in a browser and stuff > rely on the URL of the thing being downloaded and when you start crossing > that with your .php URL and JavaScript's popup windows, all hell breaks > loose, as you've noted. > > Things you *might* try: > 1. Rename the getdocfile.php to getdocfile.htm and force Apache to make it a > PHP file. > > 2. Get rid of the ?file= part, and just use > /<?=$DrawingGroups->Value('filename')?> and then use $path_info in your > getdocfile.htm script instead of $_GET['file'] > > 3. Whoops. 2. conflicts with 3. You maybe be "stuck" with something really > stupid like using: > /<?=str_replace('.', '_', $DrawingGroups->Value('filename')?>.htm and then > inside of getdocfile.htm you'll need to de-construct the foo_pdf.htm back > into foo.pdf to get the file you actually want. > Yes, your URLs will now look very strange, but remember how stupid IE is? > It's really stupid. > > 4. You may even need to go so far as to have the popup window have a META > tag to re-locate to the actual document you want, so that only an HTML > document is the first thing to appear in the popup window. Again, IE is > really stupid, and as soon as you cross a popup with a non-HTML document (of > certain types you have begun to discover empirically) it screws up. > > I never have figured out which/why/when IE screws up popups with non-HTML > content and don't really care cuz I hate popups... But it's a known issue, > and there's not much you can do about it other than make IE happy by > following the adage: "Don't do that."
Richard, Did you see my reply to your recent response to David Buerer in "Re: set filename of file open/download"? After searching everything I could find on the subject, and hours of trying as many combinations of headers as I could think of, I got everything to work the way I wanted in "both" IE and NN. The pop-up pops up. The jpg and pdf, etc. files open in the windows. If it's an xls or some such file, the dialog asks if I want to save or open. Whatever my response, it knows the filename and behaves as requested. Hard to believe. :) I believe the key was to add: header('Cache-Control: public'); Any thoughts as to why this is needed for MSIE. Roger -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php