Hey I want ot download a text file but with the code below it opens the text file in a new window.
Whats the code to make that when i click the link the file can be downloaded onto my computer.Code:<a href="textfile.txt">download here</a>
Thanks![]()
Hey I want ot download a text file but with the code below it opens the text file in a new window.
Whats the code to make that when i click the link the file can be downloaded onto my computer.Code:<a href="textfile.txt">download here</a>
Thanks![]()
Last edited by batman1; 06-12-2009 at 10:49 PM.
That -is- the code to download it to pc - your systems browser is set to a different action by default however, so it's not having the intended effect.
In short the code is right, the browser's doing it wrong - not really a way to code it so it forces it to download that I know of, other than right-click, save-target-as![]()
TOS breakers will be suspended regardless of race, creed, national origin, hair color, or favorite food. Thanks for your understanding!
Once it opens in a new window, click file...save as. You have already downloaded it! What browser are you using?
I believe many browsers can view .txt files. So, by default they open them, similar to a .html file. Maybe this will help: http://stackoverflow.com/questions/186867?sort=votes
gjr.gr - coming soon: secrets of OCD coding from a self taught tinkerer
If you add it to a zip folder and upload it to the server and then link to the folder it should download.
For great installation & servicing of Audio Visual systems & equipmentinc. LCD & Plasma Screens, Loudspeakers, Projectors, Aerials & Satellite Dishes, Lighting effects & controllers, Hifi, Amplifiers, Surround Sound, Home Cinema & Video etc-: based around Plymouth, Devon, or anywhere in the southwest of the UK, visit :-
I guess it depends on the size of the text file. If you're zipping a 10kb text file (like most of them are) you really gain nothing by zipping it. Unless you anticipate your users are on 14.4kbs dialup. The .zip extension just guarantees that your browser won't try to open it. But, you can do the same thing with the link I posted above and use any file extension ;)
gjr.gr - coming soon: secrets of OCD coding from a self taught tinkerer
You have send the header to download the file. It involves a little PHP or another web language. PHP is the one I know though. Put this code in a file called text.php or something. Of course you have to change the Content-Length parameter.
Code:<?php header('Content-Type: text/plain'); header('Content-Length: 1234'); header('Content-Disposition: attachment;filename="textfile.txt"'); $fp=fopen('textfile.txt','r'); fpassthru($fp); fclose($fp); ?>
I understand the text file problem, but why then do certain images enforce a download rather that just viewing them? That can get really irritating when image searching.