Send E-mail When Uploading

SBasis

New Member
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
}
?>
 

jnjc

New Member
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.";

[B]------  Insert mail code here ------[/B]

} else{

Do a google on phpmailer or something similar
 

conor

New Member
taken from http://ie2.php.net/mail

<?php

Code:
$Name = "Da Duder"; //senders name
$email = "[email protected]"; //senders e-mail adress
$recipient = "[email protected]"; //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 :)
?>
 
Top