473,245 Members | 1,750 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,245 software developers and data experts.

How to have email form send email and start file download

Last week after much searching, I found the answer to my problem in
this newsgroup. I can't find the thread from which I got my solution,
but I wanted to report back what worked.

When the site visitor fills out the form and submits it, this calls a
rather ordinary asp script like formmail.asp that sends the emails and
displays a "thank you" web page. At the very end of my "thank you" web
page I placed the following:

<script type="text/javascript">
location.href="FileToDownload.exe"
</script>

This causes the file download to get triggered, and asks the user if
they want to save the file. In limited testing this appears to work
fine in both Firefox and IE.

Cheers,

Brian Murphy
Austin, Texas

Apr 29 '06 #1
13 3263
bm*****@xlrotor.com wrote:
[...]
When the site visitor fills out the form and submits it, this calls a
rather ordinary asp script like formmail.asp that sends the emails and
displays a "thank you" web page. At the very end of my "thank you" web
page I placed the following:

<script type="text/javascript">
location.href="FileToDownload.exe"
</script>

This causes the file download to get triggered, and asks the user if
they want to save the file. In limited testing this appears to work
fine in both Firefox and IE.


If, and only if, the required client-side script and DOM support
is present. You are much better off doing this server-side. At
least provide a server-side fallback.
PointedEars
--
What one man can invent another can discover.
-- Sherlock Holmes in Sir Arthur Conan Doyle's
"The Adventure of the Dancing Men"
Apr 30 '06 #2
bm*****@xlrotor.com wrote:
Last week after much searching, I found the answer to my problem in
this newsgroup. I can't find the thread from which I got my solution,
but I wanted to report back what worked.

When the site visitor fills out the form and submits it, this calls a
rather ordinary asp script like formmail.asp that sends the emails and
displays a "thank you" web page. At the very end of my "thank you" web
page I placed the following:

<script type="text/javascript">
location.href="FileToDownload.exe"
</script>


This code doesn't work well in Firefox - the file is offered for
download indeed, but the "Thank you" text doesn't display (FF 1.0.4. on
WinXP SP2).

I'ld suggest not to use too much exotic artificial constructions like
that.

Why not just use:

<p>Thank you. The form has been sent</p>
<p><a href="FileToDownload.exe">Click here to
download the .exe-file</a></p>

Or

<p>Thank you. The form has been sent.</p>
<iframe width="0" height="0" src="FileToDownload.exe"
style="visibility:hidden; display:none; width:0px; height:0px">
</iframe>

--
Bart

May 1 '06 #3
I'll have to confess I can't tell the difference between something that
is client-side and server-side.

For years my "thank you" page has had a "Click here if the download
doesn't start automatically" type of link. That was necessary because
the download never did start automatically.

The two things that appeal to me the most about the three lines of jave
script are 1) it worked when I tested it in FF and IE, and 2) it's only
three lines of script.

Forgive my ignorance, but what is it about this approach that makes it
seem exotic and artificial?

At the time I found what I consider a great, simple and elegant 3 line
solution, someone else was trying to help me solve this problem by
adding mountains of indecipherable (to me) script to my web page.

Brian

May 4 '06 #4
bm*****@xlrotor.com wrote:
I'll have to confess I can't tell the difference between something that
is client-side and server-side.

For years my "thank you" page has had a "Click here if the download
doesn't start automatically" type of link. That was necessary because
the download never did start automatically.

The two things that appeal to me the most about the three lines of jave
script are 1) it worked when I tested it in FF and IE, and 2) it's only
three lines of script.

Forgive my ignorance, but what is it about this approach that makes it
seem exotic and artificial?
Your code actually tries to _replace_ your current location with the
..exe file (and not to open it as a second file). Firefox implements
this more logically than MSIE; it offers the file for download and
doesn't display the original webpage (which is closer to a literal
'location change' than MSIE, that still displays the original HTML
content).

<p>Thank you.</p>
<script type="text/javascript">
location.href="FileToDownload.exe"
</script>

Your code doesn't do what you think it does, it only looks that way.
This must sound cryptic for someone who doesn't know the difference
between server side and client side software :-)
At the time I found what I consider a great, simple and elegant 3 line
solution, someone else was trying to help me solve this problem by
adding mountains of indecipherable (to me) script to my web page.


Avoiding complexity whenever you can is definitely a good coding
strategy. You'll do yourself (or your successor) a big favour with
that.

As in my previous post, I think your best option would be something
like this:

<p>Thank you. The form has been sent.</p>
<iframe width="0" height="0" src="FileToDownload.exe"
style="visibility:hidden; display:none; width:0px; height:0px">
</iframe>

--
Bart

May 4 '06 #5
Hello Bart,

Both Firefox 1.5.0.2 and IE 6.0 seem to behave the same. First I fill
out the form, click the button, my thank_you.html page is displayed,
and a moment later the Save File dialog box appears.

If you want to see this in action:

The form is at this address www.xlrotor.com/downloads.shtml
When you click the submit button, the formmail script is called, which
send two emails (one to me and one to the visitor) and then displays
http://www.xlrotor.com/thank_you3.shtml

If you view the page source for the thank_you page, go to the very end
and you'll see the three javascript lines. The script is outside the
body of the html code for the page (I think).

I encourage you to try it out, and to please let me know what happens.

Cheers,

Brian

May 5 '06 #6
bm*****@xlrotor.com wrote:
Both Firefox 1.5.0.2 and IE 6.0 seem to behave the same. First I fill
out the form, click the button, my thank_you.html page is displayed,
and a moment later the Save File dialog box appears.

If you want to see this in action:
The form is at this address www.xlrotor.com/downloads.shtml
I get "Page not found" error for that. The URL is probably

http://www.xlrotor.com/xlrotor/downloads.shtml
When you click the submit button, the formmail script is called, which
send two emails (one to me and one to the visitor) and then displays
http://www.xlrotor.com/thank_you3.shtml

If you view the page source for the thank_you page, go to the very end
and you'll see the three javascript lines. The script is outside the
body of the html code for the page (I think).

I encourage you to try it out, and to please let me know what happens.


Yes - that works fine here too. I ran my previous test on Firefox on
the local xp filesystem (C:\Documents and Settings\etc.), where it
appears to have a different result. But I think this emphasises my
previous point.

--
Bart

May 5 '06 #7
Oops. The first url should have been
http://www.xlrotor.com/xlrotor/downloads.shtml

But you probably don't need to bother with that one if you have already
followed the second one.

I've done some more digging around about automatic file downloads.
What if I place the following line in the <HEAD> section of my
"thank_you3.shtml" page.

<META HTTP-EQUIV="Refresh" CONTENT="3; URL=http://FileToDownload.exe">

A web page I visited tonight displayed a page that had a "click here if
the file download doesn't start automatically within a few seconds".
The file download did start automatically, so I did a "view source" to
try to see how it did this, and it appears to do this using a tag like
the one shown above. The value 3 is the number of seconds to wait
before showing the specified URL. They actually had 9 seconds in their
implementation, but that seems like a long time to wait

I thought I'd ask before trying it myself. It seems to be just a one
line html tag without any scripting trickery. It would be simple to
add this line to my "thank_you3.shtml" page, and remove the js code
I've got there now.

I very much appreciate your help on this.

Brian

May 8 '06 #8
bm*****@xlrotor.com wrote:
But you probably don't need to bother with that one if you have already
followed the second one.

I've done some more digging around about automatic file downloads.
What if I place the following line in the <HEAD> section of my
"thank_you3.shtml" page.

<META HTTP-EQUIV="Refresh" CONTENT="3; URL=http://FileToDownload.exe">
Since the URL points to a nonexisting resource (_host_ FileToDownload.exe,
implicitly assuming "/" [DocumentRoot] as request URI), it is not going to
work. The best thing that can happen then is an error message box, and the
worst thing using this as search string for $search_engine and redirecting
you to the first hit.

And no UA is required to support this element type-attribute combination
anyway; in fact, there are some where it is explicitly not supported, or
where support for it can be disabled.
A web page I visited tonight displayed a page that had a "click here if
the file download doesn't start automatically within a few seconds".
The file download did start automatically, so I did a "view source" to
try to see how it did this, and it appears to do this using a tag like
the one shown above.
I am certain that there were several differences to the above.
[...]
I thought I'd ask before trying it myself.
Since when is this a Good Thing on Usenet? Asking about the why of things
you do not fully understand is OK, but there is no excuse for not trying
before posting; unless, of course, you expected it to do something harmful
and had no test environment. Did you, really?
It seems to be just a one line html tag without any scripting trickery.
It is. Read the HTML 4.01 Specification.
It would be simple to add this line to my "thank_you3.shtml" page, and
remove the js code I've got there now.


That would not help you either, unless you provided the full URL somehow
(which is best achieved with server-side scripting, as you can see on
downloads.com, sourceforge.net aso.). It can serve as a fallback for
client-side `location=...', but you SHOULD provide the download link anyway
for the reasons given above. (Remember those "<if the download does not
start, click here>" messages?)
PointedEars
--
I hear, and I forget; I see, and I remember; I do, and I understand.
-- Chinese proverb
May 10 '06 #9
I realize the URL needs to be fully qualified. I mistakenly type it
shortand for the newsgroup post. Sorry about that.

Today I witnessed a friend trying out my page that has the 3 line js
script with IE6, and it didn't start the download by itself. So I have
removed the js lines and put the following html line near the front of
the file "www.xlrotor.com/thank_you3.shtml"

<META HTTP-EQUIV="Refresh" CONTENT="3;
URL=http://www.xlrotor.com/xlrotowm30.exe">

This works when tested on my computer with IE6 and Firefox.

I need to do more testing.

Anyone who wants to try it can simply follow the link above and see if
the "file save" dialog appears about 3 seconds or so after the page
appears in your browser. The file download is 23 MB, so you probably
will want to cancel out of the download.

Brian

May 12 '06 #10
bm*****@xlrotor.com said the following on 5/11/2006 11:56 PM:

Please quote what you are replying to.

If you want to post a followup via groups.google.com, don't use the
"Reply" link at the bottom of the article. Click on "show options" at
the top of the article, then click on the "Reply" at the bottom of the
article headers.

<URL: http://www.safalra.com/special/googlegroupsreply/ >
Today I witnessed a friend trying out my page that has the 3 line js
script with IE6, and it didn't start the download by itself.
Probably has JS disabled then.

So I have removed the js lines and put the following html line near
the front of the file "www.xlrotor.com/thank_you3.shtml"

<META HTTP-EQUIV="Refresh" CONTENT="3;
URL=http://www.xlrotor.com/xlrotowm30.exe">
IE6:

Tools>Security>Custom Level

Downloads section
3 settings to ponder

Last Section, explicitly disable META Refresh
This works when tested on my computer with IE6 and Firefox.

I need to do more testing.


Yes, indeed.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
May 12 '06 #11
bm*****@xlrotor.com wrote:
<META HTTP-EQUIV="Refresh" CONTENT="3;
URL=http://www.xlrotor.com/xlrotowm30.exe">

This works when tested on my computer with IE6 and Firefox.

I need to do more testing.


Usually testing is a Good Thing, but it is the path to the Dark Side here.

You can _never_ test 100% of the cases; so you have to provide a fallback
for _unknown_ cases where a certain technique does not work due to _unknown_
reasons. You really should read (my) postings more thoroughly.
PointedEars
--
A true translation needs neither omissions nor addings.
It is its own content.
-- me, 2003
May 13 '06 #12
That's a dizzying collection of options that IE has.

So it certainly seems the automatic triggering of the file download is
hit or miss on any given system. So the "click here if the download
does not start automatically" is mandatory, and I do have this.

Unless I discover any as yet unseen problems, I think the single line
HTML META tag is the way to go for the file download. I will continue
to test it on other computers whenever the opportunity arises.

Thanks,

Brian
Randy Webb wrote:
bm*****@xlrotor.com said the following on 5/11/2006 11:56 PM:

Please quote what you are replying to.

If you want to post a followup via groups.google.com, don't use the
"Reply" link at the bottom of the article. Click on "show options" at
the top of the article, then click on the "Reply" at the bottom of the
article headers.

<URL: http://www.safalra.com/special/googlegroupsreply/ >
Today I witnessed a friend trying out my page that has the 3 line js
script with IE6, and it didn't start the download by itself.


Probably has JS disabled then.

So I have removed the js lines and put the following html line near
the front of the file "www.xlrotor.com/thank_you3.shtml"

<META HTTP-EQUIV="Refresh" CONTENT="3;
URL=http://www.xlrotor.com/xlrotowm30.exe">


IE6:

Tools>Security>Custom Level

Downloads section
3 settings to ponder

Last Section, explicitly disable META Refresh
This works when tested on my computer with IE6 and Firefox.

I need to do more testing.


Yes, indeed.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/


May 14 '06 #13
bm*****@xlrotor.com said the following on 5/14/2006 12:27 AM:
That's a dizzying collection of options that IE has.
Very dizzying.
So it certainly seems the automatic triggering of the file download is
hit or miss on any given system. So the "click here if the download
does not start automatically" is mandatory, and I do have this.
It's not mandatory, it's just the most reliable of the methods available.
Unless I discover any as yet unseen problems, I think the single line
HTML META tag is the way to go for the file download. I will continue
to test it on other computers whenever the opportunity arises.


Even knowing that META tags can be disabled and admitting that the link
is the way to go, why are you still using a faulty approach?
Answer:It destroys the order of the conversation
Question: Why?
Answer: Top-Posting.
Question: Whats the most annoying thing on Usenet?

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
May 14 '06 #14

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Mike Chirico | last post by:
Interesting Things to Know about MySQL Mike Chirico (mchirico@users.sourceforge.net) Copyright (GPU Free Documentation License) 2004 Last Updated: Mon Jun 7 10:37:28 EDT 2004 The latest...
1
by: Jeff S via AccessMonster.com | last post by:
Hello, I got some code from http://www.fabalou.com/VBandVBA/lotusnotesmail.asp to send emails atomatically from access. It works but does not attach anything to the email I am trying to email...
16
by: matt | last post by:
I have used some free code for listing files for download, but I want to send an email to the administrator when the file has been downloaded. I have got some code in here that does it, but it will...
1
by: nagamalli26 | last post by:
hai iam new php. i am creating admin side. i wrote this, phpcode: <?php //include_once("config.php"); $con=mysql_connect("localhost","root",""); mysql_select_db("happysalary"); ?>
13
by: Neil Gould | last post by:
Hi all, Thanks for the suggestions for our club's initial bulkmail sending routines. I did read up on the use of ASP vs. a separate COM app such as ASPEmail, and determined that for our club's...
6
by: Jason | last post by:
I would like to build a windows app or service that would read a .txt file and than put the contents of that file in an email and send off the email. WOuld that be very difficult?...how could this...
10
by: =?Utf-8?B?YzY3NjIyOA==?= | last post by:
Hi all, I had a program and it always works fine and suddenly it gives me the following message when a pass a xml file to our server program: error code: -1072896680 reason: XML document must...
5
by: captainB | last post by:
Hi, I'm building a simple online image gallery that allows users to download full size images for free with one condition - they must submit their name and why the chose the image. I want to use a...
27
matheussousuke
by: matheussousuke | last post by:
I'm having trouble with e-mail sending, I mean, the website is suposed to send a confirmation email after sign up, but it gets like text plain instead of HTML May someone help me, please? ...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.