/    Sign up×
Community /Pin to ProfileBookmark

How do I setup an AUTO DOWNLOAD of an EXE file?

I tried using a redirect with an exe file, and my IIS server has the proper MIME type for EXE’s.

It starts to download it, but it says application unknown and won’t ask the end user to save or run from there..

Anyone know how I can auto dowload and EXE using Javascript, or another method?

to post a comment
JavaScript

13 Comments(s)

Copy linkTweet thisAlerts:
@phpnoviceMar 28.2005 — You mean download without the user asking for it? That is not recommended. If you mean giving the user a link to click, then just ZIP the EXE and use a standard HTML link. No JavaScript required.
Copy linkTweet thisAlerts:
@rwaring1authorMar 28.2005 — No, I mean once they click a Download button. For some reason my *.exe file is unrecognized and won't allow the end user to run it or save it with the .exe extension.

I can't zip it because I'm dealing with end users who don't know zip from zap. If ya know what I mean.
Copy linkTweet thisAlerts:
@oberMar 28.2005 — I recommend you explain it to them, then. Most virus scanners will block the download of an exe file or at least throw up a hefty warning about the process.

Either way, you'd be better off using PHP to send a header with the download information.
Copy linkTweet thisAlerts:
@phpnoviceMar 28.2005 — I can't zip it because I'm dealing with end users who don't know zip from zap. If ya know what I mean.[/QUOTE]
Gotcha. Then you're going to need server-side code to create the download as an HTTP attachment -- which the browser will then open the Save As dialog box for the user to be able to specify where it should go on their harddrive. I can provide code for either ASP or PHP to do this.
Copy linkTweet thisAlerts:
@rwaring1authorMar 29.2005 — ASP would be preferred and thank you because I have no idea how to do this.
Copy linkTweet thisAlerts:
@zsivhawkMar 29.2005 — sounds interesting...what is the code for this phpnovice?
Copy linkTweet thisAlerts:
@phpnoviceMar 30.2005 — The beginning of this code can be changed to how you wish to set up which file to download.
<i>
</i>&lt;%
Dim fileName, filePath, mimeType
fileName = Request.QueryString("name")
filePath = Request.QueryString("path")
mimeType = Request.QueryString("type")
If Len(mimeType) = 0 Then
mimeType = "application/octet-stream"
End If
'
Dim adoStream, stream
Set adoStream = Server.CreateObject("ADODB.Stream")
adoStream.Open()
adoStream.Type = adTypeBinary
adoStream.LoadFromFile Server.MapPath(filePath &amp; fileName)
If adoStream.Type = adTypeBinary Then
stream = adoStream.Read()
Else
stream = adoStream.ReadText()
End If
adoStream.Close()
Set adoStream = Nothing
'
Response.Buffer = True
Response.AddHeader "content-disposition", "attachment; filename=" &amp; fileName
Response.AddHeader "content-length", Len(stream)
Response.ContentType = mimeType
Response.BinaryWrite stream
Response.Flush
%&gt;
Copy linkTweet thisAlerts:
@NashTuApr 13.2005 — Hello,

I have a problem that's about the same

Here's what i'm trying to accomplish.

I have a links page that lists rar file links from other sites.

I want to be able to specify a new filename for the files being downloaded and i know this can be done by using mime-types but i don't know how to accomplish this without streaming the content trough my webserver. I don't want to be wasting all my bandwidth on streaming files ?

For example let's say i have a file that's called downloadpage.asp that lists files

In that file i have a link to download.asp?id=10 wich redirects to http://www.anothersite.com/file.ext

I want the visitors to be promted with a save as prompt when they click save as on the link download.asp?id=10 and the prompt should have another filename (changed from file.ext to file.rar) that redirects to the real file.

Please help.. Thanks! ?
Copy linkTweet thisAlerts:
@robo_neojetsamApr 13.2005 — i wouldnt do it that way... i would have the click link because most Anti-Virus/Anti-Spyware/Firewalls might block it, because they might think its spyware/a virus.
Copy linkTweet thisAlerts:
@NashTuApr 13.2005 — I know the consequences.. but i just want to get this done without streaming the files trough my server and with dynamic renaming like i said earlier..
Copy linkTweet thisAlerts:
@phpnoviceApr 13.2005 — The only way to accomplish "dynamic renaming" of the file without streaming it from your server, is if the other site will cooperate with yours and use streaming -- to which process you would supply both the name of the desired file and the new file name.

The [b]content-disposition[/b] header is the only place you can specify an alternate name.
Copy linkTweet thisAlerts:
@NashTuApr 13.2005 — And can you give me a sample code or something? I didn't quite understand this because i'm still pretty much a newbie at asp.

Here an exact copy of the script in action but only in php (i found this a few days ago):

http://www.latest-music.com/track.php?tid=2789

Try the download link on that and see for yourself.

Thanks again for your help!
Copy linkTweet thisAlerts:
@phpnoviceApr 13.2005 — All the code I need to supply is up above in post #8. That is, of course, unless you're actually asking how I would set up a link to make the streaming request from the other site. For that, you would just redirect to something like this:
[code=html]http://www.anothersite.com/downloader.asp?file=file.ext&name=newfile.ext[/code]
On that other site, a page called [b]downloader.asp[/b] would have to be created to accept these parameters and use the code up above in post #8 to serve up the file as an attachment and give it the new name specified in the parameters.
×

Success!

Help @rwaring1 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.19,
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,
)...