0

I make a mail sender with PHP, an I want put in the mail sender upload file I have this code, but the file isn´t sent . Please help how I fix it. Thanks for responses.

    <?php 
if(isset($_POST['submit'])){
    $to = $_POST['sender']; 
    $from = $_POST['email'];
    $first_name = $_POST['first_name'];
    $last_name = $_POST['last_name'];
    $upload = $_POST['upload'];
    $subject = $_POST['predmet'];
    $subject2 = "Copy";
    $message =  $_POST['message'];
    $message2 = "Copy" . $first_name . "\n\n" . $_POST['message'];

    $headers = "From:" . $from;
    $headers2 = "From:" . $to;
    mail($to,$subject,$message,$headers,$upload);
    mail($from,$subject2,$message2,$headers2,$upload); 
    echo "E-mail sent " . $first_name . ", thanks!";
    
    }
?>

    <form action="" method="post">
Name: <input type="text" name="first_name"><br>
Surname: <input type="text" name="last_name"><br>
Sender email: <input type="text" name="email"><br>
Consignee email: <input type="text" name="sender"><br>
Subject: <input type="text" name="predmet"><br>
Text správy:<br><textarea rows="5" name="message" cols="30"></textarea><br>
<input type="submit" name="submit" value="Send email">
<label for='upload'>Upload file here: </label>
<input type="file" name="upload">
</form>
Adam
  • 67
  • 9
  • This StackOverflow post provides ways to solve this issue already - https://stackoverflow.com/questions/12301358/send-attachments-with-php-mail – hppycoder Mar 17 '21 at 17:18
  • Does this answer your question? [Send attachments with PHP Mail()?](https://stackoverflow.com/questions/12301358/send-attachments-with-php-mail) – hppycoder Mar 17 '21 at 17:18

0 Answers0