/    Sign up×
Community /Pin to ProfileBookmark

auto-saving file

I have a link to a file on a page, is there anyway I can make it so when a user clicks on the link ‘Save As’ dialog pop-up to save the file instead of displaying it?

thanks,
webtekie

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@IceMetalPunkJan 22.2004 — Hi-

As long as it is not a .txt, .htm, or .html file, the box will open automatically.

-IceMetalPunk
Copy linkTweet thisAlerts:
@webtekieauthorJan 22.2004 — not really, I have a file with .prn extension and browser still displays it.
Copy linkTweet thisAlerts:
@webtekieauthorJan 22.2004 — ok, got it working partially:
[code=php]
<li><a href="http://127.0.0.1/tmp/po.prn"
onclick="javascript:document.execCommand('SaveAs','1','http://127.0.0.1/tmp/po.prn');return false;">download</a></li>
[/code]


the problem is that if I just put po.prn it saves source code of my page. If I put url as shown, the script does not execute. Does not give any errors either.

Is that a security feature of IE?

thanks,

webtekie
Copy linkTweet thisAlerts:
@IceMetalPunkJan 28.2004 — Actually, no. the SaveAs command is only to save the site. Also, I have never heard of the extension ".prn". What kind of file is that? If the browser does not recognize the extension, that could be what's causing it to display in the window instead of saving.

-IceMetalPunk ?
Copy linkTweet thisAlerts:
@webtekieauthorJan 29.2004 — I am able to save, I just pass the url where file is located and that's what's being saved. But you are correct, if I don't pass anything then page is being saved.

xxx.prn is just an extension I use for printable content.

webtekie
×

Success!

Help @webtekie spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...