This is my view.vue file which it included a form to let user to fill in.
<v-form ref="form" lazy-validation style="width:70%;margin:4% auto;" ENCTYPE="text/plain">
<input type="text" v-model="ob_name">
<input type="file" ref="file1">
<v-btn @click="createContact()">Confirm</v-btn>
</v-form>
Then this is my script under view.vue, i've tried to console the file and it works fine which it will show this ( file1: ► File )in DevTools Console.
createContact: function(){
formData.append('file1', this.file1);
formData.append('ob_name', this.ob_name);
this.axios({
method: 'post',
url: 'http://www.company.com/mail.php',
data: formData,
config: {
headers: {
'Content-Type':
'multipart/form-data'
}}
})
},
in mail.php. I've also tried to make the input to text instead of file type, it works too. Im able to see the content from the email. The only thing that failed to view is Type="File".
<?php
$file1= "Undefined SSM";
$ob_name = "Undefined name";
if(isset($_POST['file1'])){
$file1= $_POST['file1'];
$ob_name = $_POST['ob_name'];
}
$message = "<p>Download the file below</p>";
$message .= "<p>$file1 $ob_name</p>";
$to_email = 'myemail@gmail.com';
$subject = 'New registration';
$headers[] = 'MIME-Version: 1.0';
$headers[] = 'Content-type: text/html; charset=UTF-8';
$headers[] = 'From: Company <noreply@Company.com>';
mail($to_email, $subject, $message, implode("\r\n", $headers));
?>
I really need help, im struggling for this issue for a long time. No idea what to do.
This is the email content i received from the php, it mentioned undefined name
Is this correct for when i clicked the button and trigger the file to mail.php formData.append('ob_ssm', this.file,this.file.name);
"