Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

DesignEmbrace

macrumors newbie
Original poster
Dec 8, 2008
3
0
I am having trouble getting files to attach to emails via php. These are my codes. Please Help.
Send.html
<form id="form1" name="form1" method="post" action="send.php" Form enctype="multipart/form-data">
<label for="textarea">Send files. <br />
<br />
<span class="style3">Email</span></label>
<input name="email" type="text" id="email" size="100" />
<label for="textarea"><br />
</label>
<p>Your File
<input type="file" name"userfile"></p>
<p>
<label for="Submit"></label>
<input type="submit" name="submit" value="Submit" id="Submit" />
</p>
</form>



Send.php
<?php
$email = $_REQUEST['email'] ;
$attachment = $_FILES['userfile'] ;


mail( "email@designembrace.com", "Send Files",
$message, "From: $email", $attachment );
header( "Location: thanks.html" );

?>
 
var_dump($_FILES) it's a bit more complicated then just binary data.

I think you may need to do...

Code:
$attachment = file_get_contents($_FILES['userfile']['tmp_name']);
 
Still doesn't attach the files :(. Any other suggestions?

Probably has something to do with that not being the way to send attachments, make the proper attachment headers and then send it, you can't just dump that data into the headers and hope an attachment comes through the other end.

http://www.zend.com/zend/spotlight/sendmimeemailpart3.php

That may be helpful but over your head if you're new to PHP, I'm sure there's a class somewhere that encapsulates that and allows you to send emails easily with attachments.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.