i need help with html form that send mail via PHP with image attachment, i tried simple code and the message was sent, there is all texts and even image name but no actual image, i´m not exactly sure how to do it propperly i tried many codes but none of them works. Im horible sorry if this was already answered but i searched for few hours and could not find anything.
here is my html
<div class="uk-alert uk-alert-large uk-alert-success" style="float: right; width: 25%; padding: 30px;">Registration for competitors
<form action=".../registration.php" method="POST" enctype="multipart/form-data">
<br />Full Name:<br /> <input type="text" name="name" required/>
<br /> Country: <br />*At least one team member has to have the citizenship of the chosen country.
<br /><input type="text" name="krajina" required/> <br /> Full name of your team mate:<br />
<input type="text" name="tym" required/>
<br /> Email:<br />
<input type="text" name="email" required/> At least 3 pictures of your previous work:
<input id="fileToUpload" placeholder="Select an image to Upload" type="file" name="fileToUpload" required/>
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$tym = $_POST['tym'];
$krajina = $_POST['krajina'];
$target_dir = "images/";
$target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
$uploadOk = 1;
$imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);
if(isset($_POST["submit"])) {
$check = getimagesize($_FILES["fileToUpload"]["tmp_name"]);
if($check !== false) {
echo "File is an image - " . $check["mime"] . ".";
$uploadOk = 1;
} else {
echo "File is not an image.";
$uploadOk = 0;
}
}
$formcontent=" Uzivatel: $name \ email: $email \ jeho kolega: $tym \ z krajiny: $krajina \ sa hlasi na event Tatry ice master chalenge 2016 \ $target_file" . "\r\n";
$recipient = "test@mail.com";
$subject = "Registracia na Specialny Event";
$mailheader = "From: $email\nMIME-Version: 1.0\nContent-Type: text/html; charset=utf-8\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
echo header("Location: http://www.iceart.club/special-events");
die();
?>