/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] Attaching a file to a server-sent email

I have the following form to allow a user to send me an email. It’s continuous in the code for the page, but I separated it here so that it colors nicely. Is there a way to allow someone to attach a file with a maximum size of 6MB? If yes, what is the code for that?
Also, do you think it is a good idea to allow people to send files through a form like this? Thanks for the input.

[code=php]<?php
if (isset($_POST[‘submit’])) {
mail(“[email protected]”,”form contact”,”NAME: “.$_POST[‘fname’].” EMAIL: “.$_POST[’email’].” MESSAGE: “.$_POST[‘message’]);
echo “Thank you for contacting Wiz Creations.n”;
} else {
?>[/code]
[code=html]
<form action=”contact.php” method=”post”>
<table align=”center” width=”300″ cellspacing=”5″ border=”0″>
<tr><td align=”center”>Your Name:<br><input name=”fname” type=”text” value=”” size=35></td></tr>
<tr><td align=”center”>Your Email Address:<br><input name=”email” type=”text” value=”” size=35></td></tr>
<tr><td align=”center”>Your Message:<br><textarea wrap=”hard” name=”message” rows=8 cols=35></textarea></td></tr>
<tr><td height=”26″ align=center><input type=”submit” name=”submit” value=”Submit”>&nbsp;&nbsp;<input type=”reset” value=”Reset”></td></tr>
</table>
</form>
<?php } ?>[/code]

Is that last [COLOR=Blue]<?php } ?>[/COLOR] required?

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@NogDogJul 20.2006 — What you ask is possible, but not so trivial that I have time to write the code. I would refer you to Bokeh's post on file uploads that is "stickied" at the top of this forum to get some idea on what is involved in sending a file from a web form to the server. As far as sending attachments to an email, I use the [url=http://phpmailer.sourceforge.net/]phpmailer class[/url] to handle things like that, so you might want to take a look at it.

That last [b]<?php } ?>[/b] is probably required to close out an if block that was started earlier.
Copy linkTweet thisAlerts:
@Wiz_CreationsauthorJul 20.2006 — Oh. I appologize. I didn't realize that was there. Thanks for the response.
×

Success!

Help @Wiz_Creations spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...