iceman023 Posted June 21, 2009 Share Posted June 21, 2009 I was just wondering, is there anyway i can get an email once someone has uploaded a file to my server, just to let me know that there's activity. Maybe something like a hidden submit button to send an email or something. Any ideas would be great... Thanks Link to comment https://forums.phpfreaks.com/topic/163106-solved-once-file-is-uploaded-to-server-can-i-get-an-alert-email/ Share on other sites More sharing options...
joel24 Posted June 21, 2009 Share Posted June 21, 2009 user the mail function http://au2.php.net/manual/en/function.mail.php .. put something like this in your code after the file has been uploaded $message = "A file has been uploaded!"; mail('[email protected]', 'File Uploaded', $message); Link to comment https://forums.phpfreaks.com/topic/163106-solved-once-file-is-uploaded-to-server-can-i-get-an-alert-email/#findComment-860601 Share on other sites More sharing options...
iceman023 Posted June 21, 2009 Author Share Posted June 21, 2009 where would i put that tho..? Maybe in the value of a hidden submit button, Onclick, Function, or Action?? Link to comment https://forums.phpfreaks.com/topic/163106-solved-once-file-is-uploaded-to-server-can-i-get-an-alert-email/#findComment-860794 Share on other sites More sharing options...
pkedpker Posted June 21, 2009 Share Posted June 21, 2009 pretty simple.. if you use a POST method form.. when a file is done uploading it will trigger a $_POST['submit'] then after it triggers you can use a IF Statment where you know.. you put the filename into mysql or whatever.. if(isset($_POST['submit'])) { mail('[email protected]', 'File Uploaded', "A file has been uploaded!"); } Link to comment https://forums.phpfreaks.com/topic/163106-solved-once-file-is-uploaded-to-server-can-i-get-an-alert-email/#findComment-860809 Share on other sites More sharing options...
iceman023 Posted June 21, 2009 Author Share Posted June 21, 2009 Ok thanks very much i got it to work. Now after doing some research i want to make the email look better.. I did an include command to call a new page called alertemail.php. This time im getting an error Warning: mail() [function.mail]: SMTP server response: 451 See http://pobox.com/~djb/docs/smtplf.html. in *****alertemail.php on line 23 <?php { $to = '[email protected]'; $subject = 'Activity'; $message = ' <html> <head><title></title> </head> <body> <center> <p>A file has been uploaded to your site!</p> <p><a href="admin.php">Click here to go to admin</a></p> <p><img src="photo1.jpg" width="144" height="36"></p> </center> </body></html> '; $message = wordwrap($message, 70); $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; mail($to, $subject, $message, $headers); } ?> What do you think the problem is??? Link to comment https://forums.phpfreaks.com/topic/163106-solved-once-file-is-uploaded-to-server-can-i-get-an-alert-email/#findComment-860850 Share on other sites More sharing options...
pkedpker Posted June 21, 2009 Share Posted June 21, 2009 Ok thanks very much i got it to work. Now after doing some research i want to make the email look better.. I did an include command to call a new page called alertemail.php. This time im getting an error Warning: mail() [function.mail]: SMTP server response: 451 See http://pobox.com/~djb/docs/smtplf.html. in *****alertemail.php on line 23 <?php { $to = '[email protected]'; $subject = 'Activity'; $message = ' <html> <head><title></title> </head> <body> <center> <p>A file has been uploaded to your site!</p> <p><a href="admin.php">Click here to go to admin</a></p> <p><img src="photo1.jpg" width="144" height="36"></p> </center> </body></html> '; $message = wordwrap($message, 70); $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; mail($to, $subject, $message, $headers); } ?> What do you think the problem is??? try replacing the message with this $message = '\r\n <html>\r\n <head><title></title>\r\n </head>\r\n <body>\r\n <center>\r\n <p>A file has been uploaded to your site!</p>\r\n <p><a href="admin.php">Click here to go to admin</a></p>\r\n <p><img src="photo1.jpg" width="144" height="36"></p>\r\n </center>\r\n \r\n </body></html>\r\n '; no guarantees that will do anything. Link to comment https://forums.phpfreaks.com/topic/163106-solved-once-file-is-uploaded-to-server-can-i-get-an-alert-email/#findComment-860859 Share on other sites More sharing options...
iceman023 Posted June 21, 2009 Author Share Posted June 21, 2009 Yes thank you, i have fix that error now.. Now everything looks good but i want a link within the email.. The problem is, is that it just appears as text "NO LINK" I echoed out $messages and opened the page in a browser and the link works there. Just not in an email. Why do you think this is.. Link to comment https://forums.phpfreaks.com/topic/163106-solved-once-file-is-uploaded-to-server-can-i-get-an-alert-email/#findComment-860881 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.