I have talked with the ISP about this, and they say they will charge me $80 for 2hours time to add in the appropriate code and make it to where the files with forward to the companies email box.
Is this a reasonable fee?
TIA
If you learn perl this is an easy task, and an ISP would be wise to have a canned solution handy that they could provide cheaply, but since they don't, depending on your country/area, sounds ok-ish to me. The 2 hours could be a minimum, from working with many client sites I know you never know what you're getting into when you take on a seemingly simple project.
#!/usr/bin/perl
$SENDMAIL = '/usr/sbin/sendmail';
$SCRIPT = $ENV{'SCRIPT_NAME'};
$upload_dir = "/resum_1";
$query = new CGI;
$filename = $query->param("photo");
$email_address = $query->param("email_address");
$filename =~ s/.*[\/\\](.*)/$1/;
$upload_filehandle = $query->upload("photo");
open UPLOADFILE, ">$upload_dir/$filename";
binmode UPLOADFILE;
while ( <$upload_filehandle> )
{
print UPLOADFILE;
}
close UPLOADFILE;
#### Do standard HTTP stuff ####
&cgi_receive;
&cgi_decode;
&cgi_header;
#### Make sure all necessary variables for email message are filled in
($FORM{'subject'}) ¦¦ ($FORM{'subject'} = "Company Info Request [WWW]");
($FORM{'email'}) ¦¦ ($FORM{'email'} = "anonymous\@email");
#### Send to List
open (MAIL, "¦ $SENDMAIL -O ErrorMode=q email\@email.com,$FORM{'email'},owenc\@example.com") ¦¦ die ("$SCRIPT: Can't open $mailprog: $!\n");
print MAIL "From: $FORM{'email'} ($FORM{'name'})\n";
print MAIL "To: email\@email.com \n";
print MAIL "Cc: $FORM{'email'}\n";
print MAIL "Errors-To: hubris\@example.com\n";
print MAIL "Subject: $FORM{'subject'}\n\n";
print MAIL "Name: $FORM{'name'}\n";
print MAIL "Email: $FORM{'email'}\n";
print MAIL "\n";
print MAIL "My mailing address:\n";
print MAIL "P.O. Box: $FORM{'pobox'}\n" if $FORM{'pobox'};
print MAIL "Street: $FORM{'street'}\n" if $FORM{'street'};
print MAIL "City: $FORM{'city'}\n";
print MAIL "State: $FORM{'state'}\n";
print MAIL "Zip: $FORM{'zipcode'}\n";
print MAIL "Phone: $FORM{'phone'}\n";
print MAIL "Extension: \n" if $FORM{'extention'};
print MAIL "\n";
print MAIL "\n" if $FORM{'comments'};
print MAIL "Additional Comments:\n" if $FORM{'comments'};
print MAIL "\n" if $FORM{'comments'};
print MAIL "$FORM{'comments'}\n" if $FORM{'comments'};
print MAIL "\n";
print MAIL "=============================================================\n";
print MAIL "This mail was generated automatically. Please report any\n";
print MAIL "problems to email\@email. Requester was:\n";
print MAIL "=============================================================\n";
print MAIL "REMOTE HOST: $ENV{'REMOTE_HOST'}\n";
print MAIL "REMOTE ADDRESS: $ENV{'REMOTE_ADDR'}\n";
print MAIL "HTTP_USER_AGENT: $ENV{'HTTP_USER_AGENT'}\n";
print MAIL "=============================================================\n";
print MAIL "\n";
close (MAIL);
#### Now, redirect if "next-url" is included
if ($FORM{'next-url'}) {
print "Location: $FORM{'next-url'}\n";
print "\n";
exit;
}
#### Prevent HTML output
foreach $key (keys %FORM) {
$FORM{$key} =~ s/</\</g;
$FORM{$key} =~ s/>/\>/g;
}
#### Output confirmation message ####
print qq¦<HTML><HEAD><TITLE>Thank You</TITLE></HEAD><BODY BGCOLOR="#FFFAE4" text="#3366cc" link="#0000E8" vlink="#FF0000">\n¦;
print qq¦<H1><center>Thank You For Your Submission</center></H1>\n¦;
print qq¦<center>Your resume has been sent to .</center> ¦;
print "<p>\n";
print qq¦ <center>Return to<A HREF="/">back to web link here</A></center>¦;
print "</BODY>\n";
exit;
#####################################################################
#### SUBROUTINES ####################################################
sub error_blank_field {
local($variable) = @_;
print "\n" if ($FORM{'next-url'});
print "<HTML><HEAD><TITLE>Comments Form Error</TITLE></HEAD><BODY>\n";
print "<H1>Error Processing Your Comments!</H1>\n";
print "You did not fill in $variable.\n";
print "Please go back to the form and do so.\n";
print "</BODY>\n";
exit;
}
sub cgi_header {
print "Content-type: text/html\n";
print "\n" unless ($FORM{'next-url'});
}
sub cgi_receive {
if ($ENV{'REQUEST_METHOD'} eq "POST") {
read(STDIN, $incoming, $ENV{'CONTENT_LENGTH'});
}
else {
$incoming = $ENV{'QUERY_STRING'};
}
}
sub cgi_decode {
@pairs = split(/&/, $incoming);
foreach (@pairs) {
($name, $value) = split(/=/, $_);
$name =~ tr/+/ /;
$value =~ tr/+/ /;
$name =~ s/%([A-F0-9][A-F0-9])/pack("C", hex($1))/gie;
$value =~ s/%([A-F0-9][A-F0-9])/pack("C", hex($1))/gie;
#### Strip out semicolons unless for special character
$value =~ s/;/$$/g;
$value =~ s/&(\S{1,6})$$/&\1;/g;
$value =~ s/$$/ /g;
$value =~ s/\¦/ /g;
$value =~ s/^!/ /g; ## Allow exclamation points in sentences
#### Skip blank text entry fields
next if ($value eq "");
#### Check for "assign-dynamic" field names
#### Mainly for on-the-fly input names, especially checkboxes
if ($name =~ /^assign-dynamic/) {
$name = $value;
$value = "on";
}
#### Allow for multiple values of a single name
$FORM{$name} .= ", " if ($FORM{$name});
$FORM{$name} .= $value;
}
}
[edited by: jatar_k at 3:57 pm (utc) on June 26, 2005]
[edit reason] generalized emails [/edit]
(1) You may need to add the statement:
use CGI;
right after the #!/usr/bin/perl shebang line in order to load the CGI module.
(2) The script reads the <form> data with CGI in order to store the uploaded resume file, and then tries to read it again later at "&cgi_receive;". This may need recoding to rely strictly on the CGI module functions.
(3) At some point, I would probably also suggest that the script be modified to include the $filename in the EMail so that you know which user uploaded which file. As it is now, the script gobbles up the file and stores it away in the directory $upload_dir without ever telling anyone which file is which. Also, since the script copies the user's original file name, there needs to be some error-checking in order to prevent "file name in use" (a.k.a. "file already exists") errors. As it stands, if a user selects a file name that's already in use, the new submission will simply overwrite the old one.
I hesitate to suggest it because I see you have a lot invested in this script already, but you might want to check out one of the many script sites like HotScripts dot com for a formmail script with file upload capabilities. It will mean using a generic script, but would probably be simpler and more reliable if you aren't comfortable writing new code on your own. Good luck!
The comments in this thread [webmasterworld.com] will be helpful in figuring out what's going on, particularly the ones in reference to error checking.
Also because we can't see it - it's VERY important that on an upload, your submit form includes the encoding type of multipart-form/data:
<form method="post" name="mailer" action="yourscript" ENCTYPE="multipart/form-data">