|
|||
|
I have an html web page with a button called "Download". When a user presses
this button it enables immediate download of a file stored on the server. How can I add to this button (presumablly in php) the action that when the user presses the button, not only does it download the file but it also sends me an email to say that the file has been downloaded by someone? |
|
|
||||
|
||||
|
|
|
|||
|
Mike Glazer wrote:
> I have an html web page with a button called "Download". When a user > presses this button it enables immediate download of a file stored on the > server. How can I add to this button (presumablly in php) the action that > when the user presses the button, not only does it download the file but > it also sends me an email to say that the file has been downloaded by > someone? You cannot. PointedEars |
|
|||
|
Mike Glazer wrote:
> I have an html web page with a button called "Download". When a user presses > this button it enables immediate download of a file stored on the server. > How can I add to this button (presumablly in php) the action that when the > user presses the button, not only does it download the file but it also > sends me an email to say that the file has been downloaded by someone? > > Not too hard. In your download page, you can use the mail() function to send you an email when the file is downloaded. See http://www.php.net/manual/en/function.mail.php for info on this function. It is, however, somewhat limited. If, for instance, you have to log into your mail server before sending mail, mail() won't do that. It can also be a bit awkward to use sometimes. I much prefer phpmailer - it's much more flexible. See http://phpmailer.worxware.com/ for more info. -- ================== Remove the "x" from my email address Jerry Stuckle JDS Computer Training Corp. jstucklex@attglobal.net ================== |
|
|||
|
"Jerry Stuckle" <jstucklex@attglobal.net> wrote in message news:hn5rer$a67$1@news.eternal-september.org... > Mike Glazer wrote: >> I have an html web page with a button called "Download". When a user >> presses this button it enables immediate download of a file stored on the >> server. How can I add to this button (presumablly in php) the action that >> when the user presses the button, not only does it download the file but >> it also sends me an email to say that the file has been downloaded by >> someone? > > Not too hard. In your download page, you can use the mail() function to > send you an email when the file is downloaded. See > http://www.php.net/manual/en/function.mail.php for info on this function. I understand how to use the mail function in php but my problem is how to trigger it as an event when the download button is pressed. The button has the following html code: <li> <p style="line-height: 200%; text-align:center"> <a href="Zips/Emax.zip"> <img border="0" id="img10" src="button44.jpg" height="29" width="145" alt="Emax (20 Meg)" onmouseover="FP_swapImg(1,0,/*id*/'img10',/*url*/'button45.jpg')" onmouseout="FP_swapImg(0,0,/*id*/'img10',/*url*/'button44.jpg')" onmousedown="FP_swapImg(1,0,/*id*/'img10',/*url*/'button46.jpg')" onmouseup="FP_swapImg(0,0,/*id*/'img10',/*url*/'button45.jpg')" fp-style="fp-btn: Brick Column 1" fp-title="Emax (20 Meg)"></a></li> So where do I place the php code and how do I get this button to activate when the button is pressed? |
|
|||
|
On Tue, 9 Mar 2010 16:28:58 -0000, Mike Glazer wrote:
> > "Jerry Stuckle" <jstucklex@attglobal.net> wrote in message > news:hn5rer$a67$1@news.eternal-september.org... >> Mike Glazer wrote: >>> I have an html web page with a button called "Download". When a user >>> presses this button it enables immediate download of a file stored on the >>> server. How can I add to this button (presumablly in php) the action that >>> when the user presses the button, not only does it download the file but >>> it also sends me an email to say that the file has been downloaded by >>> someone? >> >> Not too hard. In your download page, you can use the mail() function to >> send you an email when the file is downloaded. See >> http://www.php.net/manual/en/function.mail.php for info on this function. > > I understand how to use the mail function in php but my problem is how to > trigger it as an event when the download button is pressed. The button has > the following html code: ><li> > <p style="line-height: 200%; text-align:center"> ><a href="Zips/Emax.zip"> > <img border="0" id="img10" src="button44.jpg" height="29" width="145" > alt="Emax (20 Meg)" > onmouseover="FP_swapImg(1,0,/*id*/'img10',/*url*/'button45.jpg')" > onmouseout="FP_swapImg(0,0,/*id*/'img10',/*url*/'button44.jpg')" > onmousedown="FP_swapImg(1,0,/*id*/'img10',/*url*/'button46.jpg')" > onmouseup="FP_swapImg(0,0,/*id*/'img10',/*url*/'button45.jpg')" > fp-style="fp-btn: Brick Column 1" fp-title="Emax (20 Meg)"></a></li> > > So where do I place the php code and how do I get this button to activate > when the button is pressed? You change the href to point to a PHP page does the email then redirects to the file you want to send with a Location header. Google's got lots of examples of PHP redirects and the commonest problem involved with trying to make it work. -- The light at the end of the tunnel is not an oncoming train. It is muzzle-flash. |
|
|||
|
El 09/03/2010 17:28, Mike Glazer escribió/wrote:
> "Jerry Stuckle"<jstucklex@attglobal.net> wrote in message > news:hn5rer$a67$1@news.eternal-september.org... >> Mike Glazer wrote: >>> I have an html web page with a button called "Download". When a user >>> presses this button it enables immediate download of a file stored on the >>> server. How can I add to this button (presumablly in php) the action that >>> when the user presses the button, not only does it download the file but >>> it also sends me an email to say that the file has been downloaded by >>> someone? >> >> Not too hard. In your download page, you can use the mail() function to >> send you an email when the file is downloaded. See >> http://www.php.net/manual/en/function.mail.php for info on this function. > > I understand how to use the mail function in php but my problem is how to > trigger it as an event when the download button is pressed. PHP runs on the server, some seconds before and some kilometres away of your client-side buttons and events. In order to run a PHP script you have to request the script that contains it to the remove server that hosts it. What's your level of PHP experience? It looks like you've worked with client-side scripting and this is the first time you try to add some PHP functionality. If that's the case, you should really find a tutorial about PHP basics. It'll be faster in the long term that trying to code blindly. Seriously. > The button has > the following html code: > <li> > <p style="line-height: 200%; text-align:center"> > <a href="Zips/Emax.zip"> > <img border="0" id="img10" src="button44.jpg" height="29" width="145" > alt="Emax (20 Meg)" > onmouseover="FP_swapImg(1,0,/*id*/'img10',/*url*/'button45.jpg')" > onmouseout="FP_swapImg(0,0,/*id*/'img10',/*url*/'button44.jpg')" > onmousedown="FP_swapImg(1,0,/*id*/'img10',/*url*/'button46.jpg')" > onmouseup="FP_swapImg(0,0,/*id*/'img10',/*url*/'button45.jpg')" > fp-style="fp-btn: Brick Column 1" fp-title="Emax (20 Meg)"></a></li> > > So where do I place the php code and how do I get this button to activate > when the button is pressed? > > -- -- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain -- Mi sitio sobre programación web: http://borrame.com -- Mi web de humor satinado: http://www.demogracia.com -- |
|
|||
|
Thomas 'PointedEars' Lahn wrote:
> Mike Glazer wrote: > >> I have an html web page with a button called "Download". When a user >> presses this button it enables immediate download of a file stored on the >> server. How can I add to this button (presumablly in php) the action that >> when the user presses the button, not only does it download the file but >> it also sends me an email to say that the file has been downloaded by >> someone? > > You cannot. > Maybe. I can tho ;-) Unusual for you to be wrong Thomas.. > > PointedEars |
|
|||
|
Mike Glazer wrote:
> "Jerry Stuckle" <jstucklex@attglobal.net> wrote in message > news:hn5rer$a67$1@news.eternal-september.org... >> Mike Glazer wrote: >>> I have an html web page with a button called "Download". When a user >>> presses this button it enables immediate download of a file stored on the >>> server. How can I add to this button (presumablly in php) the action that >>> when the user presses the button, not only does it download the file but >>> it also sends me an email to say that the file has been downloaded by >>> someone? >> Not too hard. In your download page, you can use the mail() function to >> send you an email when the file is downloaded. See >> http://www.php.net/manual/en/function.mail.php for info on this function. > > I understand how to use the mail function in php but my problem is how to > trigger it as an event when the download button is pressed. The button has > the following html code: > <li> > <p style="line-height: 200%; text-align:center"> > <a href="Zips/Emax.zip"> > <img border="0" id="img10" src="button44.jpg" height="29" width="145" > alt="Emax (20 Meg)" > onmouseover="FP_swapImg(1,0,/*id*/'img10',/*url*/'button45.jpg')" > onmouseout="FP_swapImg(0,0,/*id*/'img10',/*url*/'button44.jpg')" > onmousedown="FP_swapImg(1,0,/*id*/'img10',/*url*/'button46.jpg')" > onmouseup="FP_swapImg(0,0,/*id*/'img10',/*url*/'button45.jpg')" > fp-style="fp-btn: Brick Column 1" fp-title="Emax (20 Meg)"></a></li> > > So where do I place the php code and how do I get this button to activate > when the button is pressed? > > Nah. You is doing it all wrong. your button merely needs to be a URL that calls up e.g. download_image.php?id=image03712965 Now, download_image.php has to do three things: 1/. Stream an image down with the correct headers 2/. send an email 3/. Spit out *absolutely nothing else*. Not even a line feed. The headers need to be whatever it is that makes it a 'download' rather than an onscreen displayed image. The mail is trivial. Basically, if you click on something that sends 'image' headers, or appears to be HTML, the page will change to display that content: You don't want that, so the headers have to be something that is guaranteed to download. using exit() as soon as the job is done rather than letting the script run out, usually solves the problem of unnoticed whitepace somewhere cater the closing tag. |
|
|||
|
Peter H. Coffin wrote:
> On Tue, 9 Mar 2010 16:28:58 -0000, Mike Glazer wrote: >> [...] >> So where do I place the php code and how do I get this button to >> activate when the button is pressed? > > You change the href to point to a PHP page does the email then redirects > to the file you want to send with a Location header. Google's got lots > of examples of PHP redirects and the commonest problem involved with > trying to make it work. All this has nothing to do with the event that the file *has been* downloaded. AFAIK it is not possible to find out that the download has happened because there would need to be a DOM event type for which an event listener has been added that in turn notified the server. Not only that AFAIK there is no such DOM event type, but client-side side scripting may also not be available. PointedEars |
|
|||
|
Thomas 'PointedEars' Lahn wrote:
> Peter H. Coffin wrote: > >> On Tue, 9 Mar 2010 16:28:58 -0000, Mike Glazer wrote: >>> [...] >>> So where do I place the php code and how do I get this button to >>> activate when the button is pressed? >> You change the href to point to a PHP page does the email then redirects >> to the file you want to send with a Location header. Google's got lots >> of examples of PHP redirects and the commonest problem involved with >> trying to make it work. > > All this has nothing to do with the event that the file *has been* > downloaded. AFAIK it is not possible to find out that the download has > happened because there would need to be a DOM event type for which an event > listener has been added that in turn notified the server. Not only that > AFAIK there is no such DOM event type, but client-side side scripting may > also not be available. > > > PointedEars Thomas: I have no real proof that you even exist: Some things you have to take on trust, and strong probability ;-) |
|
|||
|
"Mike Glazer" <glazer@physics.ox.ac.uk> wrote in message
news:hn5op7$r15$1@news.ox.ac.uk... >I have an html web page with a button called "Download". When a user >presses this button it enables immediate download of a file stored on the >server. How can I add to this button (presumablly in php) the action that >when the user presses the button, not only does it download the file but it >also sends me an email to say that the file has been downloaded by someone? If you're merely trying to track the event then using something like Google Analytics would surely be a less painful solution? Just add the track event code into the anchor. -- +mrcakey |
|
|||
|
>So where do I place the php code and how do I get this button to activate
>when the button is pressed? Write a php script with the name of the file to be downloaded and have the PHP script do the following: 1. Output headers for the particular file type involved e.g. Content-type: image/jpeg 2. Output the file data with, for example, fpassthru(). The actual file to be downloaded should be *outside* the document tree so this script is the only way to download it. 3. Have the script send the email. You might reverse #2 and #3. Ensure that the mailing process cannot generate any output (error messages) on the web page. Which is more important, getting the mail (even if the download is not started) or starting the download (even if the mail isn't sent if the script gets aborted early). |
|
|
![]() |
| Popular Tags in the Forum |
| email, send |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Re: smtplib send email by using gmail smtp server | Gabriel Genellina | Newsgroup comp.lang.python | 0 | 05-03-2009 06:08 PM |
| Re: outlook email - another problem | Alan Churchill | Newsgroup comp.soft-sys.sas | 0 | 07-02-2008 04:53 PM |
| Send an email to the users | DP | Newsgroup comp.soft-sys.sas | 1 | 02-29-2008 08:04 PM |
| Re: Sending HTML email | Duell, Bob | Newsgroup comp.soft-sys.sas | 0 | 07-27-2007 06:43 PM |
| Re: Read/Write Microsoft Word document | William W. Viergever | Newsgroup comp.soft-sys.sas | 0 | 05-31-2006 08:46 PM |