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