on 24/02/03 1:01 AM, Anthony Rodriguez ([EMAIL PROTECTED]) wrote:

> In PHP, is there a way to allow the user to download a file (e.g.:
> sample.txt) to their computer? And, then, automatically return to the
> PHP-generated Web page.

why do you need to re-run the page?  it can be done with a bit of messing
around, but i can't imagine why :)

you can force the download of a file by setting the correct headers using
header() and passing the file through.  see the user notes on
http://php.net/header.


if you're only talking about text files, then why not simply do <a
href='blah/sample.txt' target='_blank'>click</a> ???

This will pop it up in a new window, leave the original window untouched,
and they can choose "save as" from the file menu.

if for some reason you DO want the original window to be refreshed, this
could easily be done with a javascript onclick event in the above <a> tag.


> How can the file be stored in C:\sample.txt, for example?

you have no control over where the user downloads the file to -- it's
entirely up to them and/or their browser settings.  actually, "forcing a
download" really isn't true... in most cases your really "forcing a 'save
file as...' dialogue window.


Justin



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to