I don't think that should have a negative effect. My code checks to see if a file was actually uploaded and that there was no error with the upload so maybe there is a problem there. I'm an idiot - I had the correct action in my form, but had the JS validation linking to a different form action the same without the file upload. Thank you so much!! You can check the extension of the uploaded file name, but this can't really be trusted.
The mime-type of the file is also sent but this also can't be trusted. If you have PHP 5. Prior to PHP 5. One more question I can't fine the mime-type for that? Show 7 more comments. Hugo Dozois 7, 12 12 gold badges 51 51 silver badges 57 57 bronze badges.
Imtiaz Ahmad Imtiaz Ahmad 99 1 1 silver badge 1 1 bronze badge. This code help me in Attachment sending Code with above code. Irshad Khan Irshad Khan 4, 2 2 gold badges 39 39 silver badges 37 37 bronze badges.
Abdulhakim Zeinu Abdulhakim Zeinu 1, 21 21 silver badges 27 27 bronze badges. Note that you WILL have to validate that the upload actually succeeded, e. Marc B Marc B k 40 40 gold badges silver badges bronze badges. Can you provide me with what I would actually put in the AddAttachment ; part?
Rotimi Rotimi 4, 4 4 gold badges 17 17 silver badges 27 27 bronze badges. Active Oldest Votes. Improve this answer. Travis 4 4 silver badges 15 15 bronze badges. I was the same - wanted to use mail just because I already had it in my code.
But using it requires to needlessly import another thing to trust i. To not blindly trust one would require one to look at the at least lines sloc Given the alternative purely mail using answers this seems like a worse tradeoff. The alternative answers can do with less then sloc. Dislike that the answer for "I want A" is answered with "No, use B its better". The other answers tell "A is done like this". I found this question looking for an answer how to use the mail function to add attachments.
This answer does not help me do that. This isn't the answer to the question. This answer also ignores the license used by the project. Show 13 more comments. Pragnesh Chauhan Pragnesh Chauhan 8, 9 9 gold badges 39 39 silver badges 52 52 bronze badges. I'm posting the comment on his behalf since he doesn't have enough rep to post comments and I've flagged the answer for deletion.
From PHPMailer's docs There are myriad overlapping RFCs, requiring tight adherence to horribly complicated formatting and encoding rules - the vast majority of code that you'll find online that uses the mail function directly is just plain wrong! I've used something like this answer to send mail with attachments and it worked! Only to find a few days later that while Gmail shows the attachments just fine, other providers show the base64 content directly inline in the mail.
Show 9 more comments. For PHP 5. Harshil Modi 1 1 gold badge 3 3 silver badges 13 13 bronze badges. Simon Mokhele Simon Mokhele 3, 3 3 gold badges 19 19 silver badges 21 21 bronze badges. I thought the variables were descriptive enough to declare and institution them — Simon Mokhele. This finally worked after a headache of trying to get the stupid phpmailer thing to work. This one actually worked. The accepted answer was not working for me.
It would send over the file corrupted. This is a very clear and clean answer. It works when received by Outlook, Gmail alike. Neat answer. If you can update with HTML message part, this will become more complete. Show 15 more comments. Matthew Johnson Matthew Johnson 4, 2 2 gold badges 36 36 silver badges 49 49 bronze badges. Save Article. Like Article. Create an HTML form : html.
Recommended Articles. Article Contributed By :. Easy Normal Medium Hard Expert. Writing code in comment? Please use ide. Load Comments. What's New. Most popular in PHP. How to execute PHP code using command line?
0コメント