my form does not take or submit any attachment file and has the enctype and method attributes inside the form element. It looks like this:
<form action="vsend.php" class="volunteerAppForm" method="post" onsubmit="return validateForm()" role="form" enctype="multipart/form-data">
<div class="fileUploadSection">
<label for="fileToUpload">Please upload your CV</label><br>
<input type="file" name="file" id="fileToUpload" required>
</div>
<div class="captcha">
<div class="g-recaptcha" data-sitekey="6Ld071QUAAAAAIutKo0CkibGU8oeaomD5niSfNiX"></div>
<input type="submit" name='submit' value="send" class="submit-input" style="cursor: pointer;">
</div>
</form>
I debugged my codes, the problem was in my strings just in my php file here:
//Attachments
if (
isset($_FILES['uploaded_file']) &&
$_FILES['uploaded_file']['error'] == UPLOAD_ERR_OK
) {
$mail->AddAttachment(
$_FILES['uploaded_file']['tmp_name'],
$_FILES['uploaded_file']['name']
);
}
As my input type attribute has a value "file", my string should also have the same name 'file' not 'uploaded_file' as showen above. Could be like so:
//Attachments
if (
isset($_FILES['file']) &&
$_FILES['file']['error'] == UPLOAD_ERR_OK
) {
$mail->AddAttachment(
$_FILES['file']['tmp_name'],
$_FILES['file']['name']
);
}