Creating a Link that forces Save As Prompt

windows

Guest
Does anyone know of a way to create a link with HTML and/or JavaScript that will allow me to create a link to a text file (with extension .txt) to not be launched into the browser but to bring up the Save As prompt in Windows? I am only interested in this behaviour in Internet Explorer 6.0+.<br />
<br />
Also, I do not want to rename my files with another extension or zip the files.This link will be clicked on by average users, so I do not want to change any IE settings for this behaviour.<!--content-->Hello Greg,<br />
<br />
Using PHP, you can do this. Make sure the link opens in a new window, to a .php file which will send the file to be Download <!--more-->ed. Use the header() (<!-- m --><a class="postlink" href="http://us2.php.net/manual/en/function.header.php">http://us2.php.net/manual/en/function.header.php</a><!-- m -->) function of PHP to do so.<br />
<br />
<br />
<?php<br />
<br />
# This code is the only thing<br />
# that should belong in the PHP <br />
# document<br />
<br />
header('Content-type: text/plain');<br />
<br />
header('Content-Disposition: attachment; filename="yourfile.txt"');<br />
?><br />
<br />
<br />
[J]ona<!--content-->An example within the .htaccess file you'ld write:<br />
<br />
code:<br />
AddType application/octet-stream .txt<!--content-->Thanks [J]ona. This eneded up working out very well - with a little tweaking.<br />
<br />
Saved me a lot of time!<br />
<br />
On to the next problem . . .<!--content-->It was my pleasure to be of assistance. :)<br />
<br />
[J]ona<!--content-->
 
Back
Top