Ok, here is what I am trying to do ..
I have a standard type of Perl script that is parsing the information that comes in from an HTML form. Such as name, address, phone, email address, etc. But, I simply want to allow the user to browser through their computer and locate a file (on their computer) and include the file as an attachment to their email - when it is sent to me. For example, if someone wanted to attach a Microsoft Word copy of their resume along with their email.
What do I need to include in my Perl script ... and HTML form - that will allow this to work ... and also operate securely and handle possible error messages, etc., etc.
Here is my standard code.
Please let me know how to modify my Perl script (and HTML form) so I can incorporate the addition of a FILE attachment to the email.
Thanks.
HERE IS MY CURRENT PERL CODE:
#!/usr/local/bin/perl
&get_form_data();
&send_email;
&print_thankyou_page;
sub get_form_data
{
# Get the input
read(STDIN, $buffer, $ENV{ 'CONTENT_LENGTH' } );
# Split the name-value pairs
@pairs = split (/&/, $buffer);
foreach $pair (@pairs)
{
($name, $value) = split(/=/, $pair);
# Un-Webify plus signs and %-encoding
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9]
)/pack("C"
,
hex($1))/eg;
$value =~ s/<!--(.|\n)*-->//g;
$FORM{$name} = $value;
}
}
sub send_email
{
$to = "my\@emailaddress.com";
$mailprog = '/usr/lib/sendmail';
open(MAIL,"|$mailprog -t");
print MAIL "From: $FORM{'email'}\n";
print MAIL "To: $to\n";
print MAIL "Subject: Email Message \n\n";
# print out the form results
print MAIL "First Name: \t$FORM{'first_name'} \n\n";
print MAIL "Last Name: \t$FORM{'last_name'} \n\n";
print MAIL "E-mail Address: \t$FORM{'email'} \n\n";
print MAIL "Status: \t$FORM{'status'} \n\n";
print MAIL "Other \(if other is selected for Status\): \t$FORM{'other'} \n\n";
print MAIL "Comments: \t$FORM{'comments'} \n\n";
print MAIL " \n";
close(MAIL);
}
sub print_thankyou_page
{
print "Content-type: text/html\n\n";
print "<HTML>\n<HEAD>\n</HEAD>\n
<BODY BGCOLOR=\"#FFFFFF\">\n";
print "<font face='arial, verdana, helvetica' color='#336699'><H3>THANK YOU SUBMITTING YOUR INFORMATION.</H3>\n\n";
print "<P>\n";
print "We have received your comments and will forward this to the webmaster.<BR><BR><BR>\n";
print "Click below to return back:<BR>\n";
print "<B><A HREF=\"
http://www.ourwebsite.com/\" TARGET=\"\_top\">Our Company</A></B></font><BR>
<BR>\n\n\n
";
print "</BODY>\n</HTML>";
}
The HTML page can be found at:
http://www.piccorp.com/hr_feedback_form.html==========================
==========
=========
I'd greatly appreciate some help on how to add this feature.
Thanks ...
Gary
PS: Depending upon what is involved to help me with this, I'd be very willing to increase the amount of points. Just let me know.