|
|
#1 |
|
New Member
![]() Join Date: Mar 2009
Posts: 2
|
Hello, I was just working on some coding. I was able to create an uploading form, where anyone who knows my web page can upload any form of media. However, I would like to know when someone does in fact upload something. Below is my code for the Browse and Submit functions. My question is: What would I add and where so that when someone uploads a file, I am sent an e-mail notification?
Thank you! <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="fileForm" id="fileForm" enctype="multipart/form-data"> <table> <tr><td><input name="upfile" type="file" size="36"></td></tr> <tr><td align="center"><p><input class="text" type="submit" name="submitBtn" value="Upload" > </p> </td> </tr> </table></center> </form> <?php if (isset($_POST['submitBtn'])){ ?> <div id="caption">Result:</div> <div id="result"> <table width="100%"> <?php $target_path = $_SERVER['DOCUMENT_ROOT'] . '/videos/' . basename( $_FILES['upfile']['name']); if(move_uploaded_file($_FILES['upfile']['tmp_name'], $target_path)) { echo "The file: ". basename( $_FILES['upfile']['name']). " has been sucessfully uploaded."; } else{ echo "There was an error uploading the file, but please try again."; } ?> </table> </div> <?php } ?> |
|
|
|
|
|
#2 |
|
Super Moderator
![]() Join Date: Jun 2008
Posts: 493
|
All you need to do is put a call to one of the php mail routines in your code:
Code:
$target_path = $_SERVER['DOCUMENT_ROOT'] . '/videos/' . basename( $_FILES['upfile']['name']);
if(move_uploaded_file($_FILES['upfile']['tmp_name'], $target_path)) {
echo "The file: ". basename( $_FILES['upfile']['name']).
" has been sucessfully uploaded.";
------ Insert mail code here ------
} else{
|
|
|
|
|
|
#3 |
|
Gold Member
![]() Join Date: Oct 2008
Location: Ireland
Posts: 349
|
taken from http://ie2.php.net/mail
<?php Code:
$Name = "Da Duder"; //senders name $email = "email@adress.com"; //senders e-mail adress $recipient = "PersonWhoGetsIt@emailadress.com"; //recipient $mail_body = "The text for the mail..."; //mail body $subject = "Subject for reviever"; //subject $header = "From: ". $Name . " <" . $email . ">\r\n"; //optional headerfields mail($recipient, $subject, $mail_body, $header); //mail command :) ?>
__________________
Conor |
|
|
|
|
|
#4 |
|
New Member
![]() Join Date: Mar 2009
Posts: 2
|
Thank you very much. It worked perfectly. I really appreciate it.
|
|
|
|
![]() |
| Tags |
| code, email, form, java, upload |
| Thread Tools | |
| Display Modes | |
|
|