|
|
|
|
![]() ![]() |
Oct 21 2005, 04:38 AM
Post
#1
|
|
|
Super Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 383 Joined: 8-October 05 Member No.: 12,656 |
i know there are a few topics talk about attachment problem, but i want to know if anyone could show me a basic code for attaching files like pictures with the message.
I made a html form, and redirect the information to my mail.php file to process the information and send it to my email. I want to know what do i have to do to attach files like pictures. I tried to search on google, and the codes are so complicated (i'm an amateur at this). Would it be possilbe if you could show me the code and explain to me what it does and how i could customize it to fit my needs? thankyou |
|
|
|
Oct 22 2005, 09:41 PM
Post
#2
|
|
|
Super Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 383 Joined: 8-October 05 Member No.: 12,656 |
CODE // In PHP earlier then 4.1.0, $HTTP_POST_FILES should be used instead of // $_FILES. In PHP earlier then 4.0.3, use copy() and is_uploaded_file() // instead of move_uploaded_file $uploaddir = '/public_html/site/html/uploads/'; $uploadfile = $uploaddir. $_FILES['userfile']['name']; print "<pre>"; if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) { print "File is valid, and was successfully uploaded. "; print "Here's some more debugging info:\n"; print_r($_FILES); } else { print "Possible file upload attack! Here's some debugging info:\n"; print_r($_FILES); } print "</pre>"; i found that code and when i tried to exacute the php file, it said Possible file upload attack! Here's some debugging info: Array ( [attachment] => Array ( [name] => logo.jpg [type] => image/jpeg [tmp_name] => /tmp/phpmlM3po [error] => 0 [size] => 20655 ) ) i tried to give my folders full permission and it still doesn't work. and how can I attach the uploaded file(s) to an email |
|
|
|
Oct 23 2005, 02:57 AM
Post
#3
|
|
|
Super Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 383 Joined: 8-October 05 Member No.: 12,656 |
ok.. i think i got the file to upload to my tmp folder ( i think because when i exacute the .php file , i got the message
CODE File is valid, and was successfully uploaded. Here is some more debugging info:Array ( [attachment] => Array ( [name] => logo.jpg [type] => image/jpeg [tmp_name] => /tmp/phpvzOMho [error] => 0 [size] => 20655 ) ). [/CODE So i'm guessing it works. NOw.. my question is.. how am i suppose to embed that into my mail. [CODE] <? $name=$_POST['name']; $email=$_POST['email']; $attachment= $to="example@gmail.com"; $message="Terms and Conditions: $agree \nName: $name Middle:$middle \nAge: $AGE \nDate of Birth: $month $date, $year \nWeight: $weight Pounds \nHeight: $height Inches \nAddress: $address $city, $state $code \nTelephone: $phone \nEmail: $email \nSchool: $school \nMajor: $major \nAbout $name \n $reason"; if(mail($to,"Application from $name",$message,"From: $email\n")) { echo "Thankyou for registeringt"; } else { echo "There was a problem sending the mail. Please check that you filled in the form correctly. Please Click Back"; } i dont' really know what i'm doing exactly. So please help me out. It seems like no one is bothering to help. =( |
|
|
|
Feb 7 2006, 11:58 PM
Post
#4
|
|
|
Super Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 282 Joined: 1-September 05 From: Wanatos Member No.: 11,382 |
Hi dog eater, I find myself in the same problem as you. I tried looking a little bit in google and php dot net but Im also an amateur...
I have a working php sendmail script, which I adapted from different stuff I found here and there, I didnt write the whole thing but I made the final mix... I know (guess you already know this too) how to send mail, the most basic line to achieve so is this: mail($admin_mail, $subject, $content, $headers) Where admin mail is the mail you want the message to be sent, and the headers are additional information which is optional. Subject and Content I think that are obvious. But the command to attach a file is what is missing, and I dont know either how to do it... Hope someone could help us both.. thanks in advance Ill keep browsing the web for it but would apreciate a lot yer help... |
|
|
|
Feb 8 2006, 12:20 AM
Post
#5
|
|
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 1,161 Joined: 9-May 05 From: Brisbane, QLD Member No.: 6,818 |
Make sure you're cleaning any input before sending it to your mail function.
|
|
|
|
Feb 8 2006, 01:18 AM
Post
#6
|
|
|
Super Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 282 Joined: 1-September 05 From: Wanatos Member No.: 11,382 |
How is that? cleaning any input? You mean from the html form itself? Could you teach us how to do so? Thanx a lot Tyssen, but Im not sure if this is a tip for sending secure mail through php or actually about the thread's topic... I mean no offense...
|
|
|
|
Feb 8 2006, 05:09 AM
Post
#7
|
|
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 1,161 Joined: 9-May 05 From: Brisbane, QLD Member No.: 6,818 |
Well it doesn't necessarily relate to the topic of adding email attachments, but whenever you're using a HTML form to transmit info to your mail program via PHP, you need to be aware of the danger of 'email header injection'. A Google search on that will provide you with more and better info than I could give here.
|
|
|
|
Feb 8 2006, 07:22 PM
Post
#8
|
|
|
Newbie [Level 3] ![]() ![]() ![]() Group: Members Posts: 40 Joined: 29-January 06 Member No.: 17,841 |
|
|
|
|
Feb 9 2006, 02:10 AM
Post
#9
|
|
|
Super Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 282 Joined: 1-September 05 From: Wanatos Member No.: 11,382 |
Thanx Tyssen its a nice tip ill google it...
And kvkv thanx for that link, ill give it a try, i havent tested it yet but the main page displays this as a feature: Multiple fs, string, and binary attachments (those from database, string, etc) Im not sure if it is what i need, do you know something about it? I dont want to upload files to a database but to send them right through the form... thanks a lot! |