I have a form with upload part . after uploading the file the user click on the send button. After that i want to send the file as a attachment to the receiver mail
if you have <input type='file' name='myFile' />
in your form, on submit, all you need is to get this named field in your php file as
if( isset($_POST['myFile']) ){
// means there is file submitted
// do process it here (store, edit, delete, whatever)
}
if( isset($_POST['myFile']) ){
$attachname8=$_FILES['myFile']['name'];
$attachment8='';
$output_dir="report/";
//Filter the file types , if you want.
if(!empty($attachname8))
{
if ($_FILES["myFile"]["name"] > 0)
{
echo "Error: " . $_FILES["myFile"]["error"] . "<br>";
}
else
{
//move the uploaded file to uploads folder;
move_uploaded_file($_FILES["myFile"] ["tmp_name"],$output_dir.$_FILES["myFile"]["name"]);
$attachment8="report/".$_FILES["myFile"]["name"];
}
}
}