1

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.

8
  • Why are you catching a PDOException in a block not using PDO? Commented Mar 30, 2014 at 0:43
  • Could you do a print_r of the file? PD : stackoverflow answer ... Check if you upload a correct image format and size file in your php.ini Commented Mar 30, 2014 at 0:45
  • @Machavity,I deleted some code because I am using PDO. But to be read easily, I deleted them. Commented Mar 30, 2014 at 0:47
  • Put var_dump($_FILES); at the top of your php code and find out what is it receiving. Commented Mar 30, 2014 at 0:49
  • 1
    Yes! I got it. The error code is 1. Because it exceeds the max size. Thx guys. Commented Mar 30, 2014 at 0:54

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.