Return HTML and then a file

Return HTML and then a file

Post by jon roger » Thu, 03 Jul 2003 23:25:52



Hi

I run a couple of Perl-CGIs under the latest Apache on my Red Hat box. I
have now come across a problem.

From my script, I'd first like to return some HTML lines:

print "Content-Type: text/html\n\n<html><head><title>The TinyBox
pages</title>\n";  

etc.

Then I'd like to return a file:

print "Content-Type:application/octet-stream
Content-Disposition:attachment; filename=results.apl
Content-Length:$content_length\n\n";

However, it seems that I cannot print    
Content-Type:application/octet-stream after I have printed    
Content-Type: text/html ; the file just gets printed to screen, instead of
the browser opening a file save requester.

Is there some way of "resetting" the Content-Type: string sent to Apache, or
some other way around the problem?

Thanks for your time,

JR

 
 
 

Return HTML and then a file

Post by Scott Yanof » Thu, 03 Jul 2003 23:23:00



> Hi

> I run a couple of Perl-CGIs under the latest Apache on my Red Hat box. I
> have now come across a problem.

> From my script, I'd first like to return some HTML lines:

> Then I'd like to return a file:

You're only seeing the HTML and not the file because you've already sent
a definitive content type to the browser.

It sounds like you want a web page to show up and for it to
automatically start downloading something to the user's browser.
Perhaps you can generate the HTML with a META REFRESH tag that refreshes
to the file the user is meant to download.  Since it is just a
download-able file, I would think that the HTML would stay on the screen
while the browser's file pop-up would appear.

Good luck,

--
-Scott


 
 
 

1. /index.html return text/x-server-parsed-html?

I'm running NCSA 1.5a on RedHat Linux 2.1. Both new.

The server is working fine EXCEPT, the root file '/index.html'
is returning a mime type of text/x-server-parsed-html.

Only this file name is doing this. I added index.htm as the
first file name in the DirectoryIndex statment and it works.

User documents /~user/ also work.

Anyone have a clue?

Try it. http://www.state.ok.us/index.html

2. KDE/KFM in home dir: strange bug, any fix?

3. file.html and file.html/ give same thing

4. BQUESTION ABOUT BACKGROUND PROCESSES?

5. How to make html files with extension html work?

6. Grep using -f

7. Matrox Mystique ands X.

8. Ping script, need suggestions

9. Apache MultiViews: /dir returns /dir/, not dir.html

10. Help...Apache 1.0 returns HTML as text

11. links or lynx return raw HTML?

12. html returned not web page

13. script_name variable returning html page name calling script ??