Hi
I have a web page that runs a back end script and then presents the user with a hyperlink to a dynamically generated txt file. (the name is based on date & time)

All the backend bits are working fine, its just the downloading of the text file..

The hyperlink is similar to:

<a href="/admin/file 11.08.09 140954.txt">Click HERE</a>

How do I force the hyperlink to prompt for the save dialogue box and not open the txt file within the browser ??

Thanks

    header("Content-Type: application/force-download;");
    header('Content-Disposition: attachment; filename="yourfile.txt"');

    That is, make the href target a php file which sets those headers. Then file_get_contents on the file you want to retrieve and then echo that.

      Thanks

      I'll try that and see how I get on 🙂

        Write a Reply...