stephenkershaw Posted November 17, 2010 Share Posted November 17, 2010 Hi I'm not a coder so don't know how to write this myself. I'm very much of the copy and paste type. Basically I want a file to be downloaded and an email sent when either a link is clicked or a submit button is pressed. This is so that when a particular file hosted on my site (a pdf) is downloaded I am alerted to this by an email notification. Can anyone help me out with this? I assume that this can be done with PHP and MySQL but am open to suggestions. Thanks in advance for your help Stephen Quote Link to comment https://forums.phpfreaks.com/topic/218940-looking-for-a-script-that-sends-email-and-dowloads-file-onlick-or-other/ Share on other sites More sharing options...
stephenkershaw Posted November 17, 2010 Author Share Posted November 17, 2010 Have just thought that this could log the details of the person who is downloading the file instead of sending an email notification. Not sure if that makes things easier? Quote Link to comment https://forums.phpfreaks.com/topic/218940-looking-for-a-script-that-sends-email-and-dowloads-file-onlick-or-other/#findComment-1135566 Share on other sites More sharing options...
seanlim Posted November 17, 2010 Share Posted November 17, 2010 <a href="file.php">Download</a> <form method="post" action="file.php"> <input type="submit"> </form> file.php <?php mail("[email protected]", "File Downloaded" , "blah blah blah(include whatever info like ip address here)"); readfile("yourfilename.pdf"); ?> Quote Link to comment https://forums.phpfreaks.com/topic/218940-looking-for-a-script-that-sends-email-and-dowloads-file-onlick-or-other/#findComment-1135576 Share on other sites More sharing options...
stephenkershaw Posted November 17, 2010 Author Share Posted November 17, 2010 <a href="file.php">Download</a> <form method="post" action="file.php"> <input type="submit"> </form> file.php <?php mail("[email protected]", "File Downloaded" , "blah blah blah(include whatever info like ip address here)"); readfile("yourfilename.pdf"); ?> This looks like it is on the right lines but it is not working properly just now as the file I am linking to is a pdf. So when you click the link it loads up all the pdf as code instead of bringing up the download box. Thanks for your help so far though. Quote Link to comment https://forums.phpfreaks.com/topic/218940-looking-for-a-script-that-sends-email-and-dowloads-file-onlick-or-other/#findComment-1135596 Share on other sites More sharing options...
laffin Posted November 17, 2010 Share Posted November 17, 2010 because you still need the header content type (mime) so add this to the top of file.php header('Content-type: application/pdf'); Quote Link to comment https://forums.phpfreaks.com/topic/218940-looking-for-a-script-that-sends-email-and-dowloads-file-onlick-or-other/#findComment-1135598 Share on other sites More sharing options...
stephenkershaw Posted November 17, 2010 Author Share Posted November 17, 2010 All working now. Thanks for your help Quote Link to comment https://forums.phpfreaks.com/topic/218940-looking-for-a-script-that-sends-email-and-dowloads-file-onlick-or-other/#findComment-1135635 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.