0

Hi all,

I am giving the href to give a link to a file.
The problem is that in IE it opens the text files in the same browser, but in mozilla it works fine(gives prompt of save as option).


I want the same functionality for IE also, searching Google I found so much solution but all were saying about writing php.

I don't want to implement php, can it be done simply using by HTML,jsp and struts tag.

Regards,

5
Contributors
6
Replies
7
Views
5 Years
Discussion Span
Last Post by almostbob
1

I don't think you need php, but you will probably have to use some javascript or something if you want to force the link to be downloaded or saved.

You could use the target link attribute if you just need to stop it from opening in the same window as your current page.

0

I dont want to open it at all, what I want is the save as option should pop up. Like if some junk extension file you will give it will do.

File.asdf Link will give save as pop up
File1.doc or .txt will open the content of the file in the browser window.

0

Type the following magical incantation next to the link

"To save the file, right click the link and select Save as.."

Then the powers of darkeness and psychic forces extraordinary are invoked when the user does as he/she is told, and they can save the file.

0

Great reply drjohn, thanks for the same. But I am looking for some concrete solution. How we can pop up a window when user clicks on the link.

0

Well, a quick check using the keyword 'force download', indicates you can force downloads, but it isn't easy. The easiest way is to simply zip the file you want to have downloaded, since zipped files are always downloaded.

0

one way
<a href="pathto/savefile.php?file=pathtosomefile.txt">download somefile.txt</a>
savefile.php is below

<?php $file=$_GET['file'];
if(!$file) return false;
header("Content-disposition: attachment; filename=$file");
header('Content-type: text/plain;');
readfile("$file");
?>

Edited by almostbob

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.