I am writing a upload file page. Here's the html code:
<form action="verify.php" id="upload" method="post" enctype="multipart/form-data"> <input id="file_upload" type="file" name="file_upload" /> <button id="submit" name="submit" type="submit">Upload</button> </form> And this is my php code:
if ($_FILES['file_upload']['error']==UPLOAD_ERR_NO_FILE){ return; } try{ $email_add='[email protected]'; $subject="Driver Verification"; $mail = $this->emailConfig(); $mail->addAddress($email_add, "LALALA"); // Add a recipient $mail->Subject = $subject; echo $_FILES['file_upload']['name']; echo $_FILES['file_upload']['tmp_name']; $mail->Body = "This driver requires a verification." $mail->AddAttachment($_FILES['file_upload']['tmp_name'],$_FILES['file_upload']['name']); if(!$mail->send()) { echo 'Message could not be sent.'; echo 'Mailer Error: ' . $mail->ErrorInfo; exit; } return; } catch(PDOException $e){ return; } } So when I run the code, it just can echo ['name'] but can't echo ['tmp_name'], and thus there's no attachment in the email.
Any thoughts? Thanks.
PDOExceptionin a block not using PDO?var_dump($_FILES);at the top of your php code and find out what is it receiving.