Forum Moderators: coopster & phranque

Message Too Old, No Replies

Is this reasonable?

         

webmstr

3:45 am on Jun 22, 2005 (gmt 0)

10+ Year Member



I have created a form for a client that has an upload button for uploading resumes, and I have the form in place with Dreamweaver, and I have an old CGI script that the last web designer used...the form will work fine for the email submit part, but not for the file upload.

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

Chico_Loco

6:16 am on Jun 22, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



A bit steep. I'd suggest looking at some other uploading scripts are copying/pasting some bits and pieces. Of course, there will be a bit of a learning curve if you haven't done it before.

rocknbil

5:57 pm on Jun 23, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



$40 an hour is STEEP? That's rediculously cheap for programming work. The two hours part is a bit tall though.

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.

ikkyu

4:58 pm on Jun 25, 2005 (gmt 0)

10+ Year Member



$40 an hour is STEEP?

That definitely depends on where you live, or where your ISP is located and who they offshore their programming to.

webmstr

7:45 pm on Jun 25, 2005 (gmt 0)

10+ Year Member



Here is the code for the cgi...if anyone has a chance to take a look and see what might be wrong or missing I would appreciate it. The purpose of the script should be to enable the user to upload their resume and it should then forward to the companies email inbox. I removed their name from the script only, otherwise this is what I have so far. Thanks! I gave this to the isp, but they told me it would cost 80 to make it funtional and able to forward mail to the inbox. I just want to make sure they are telling me right before I spend the money.

#!/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/</\&lt;/g;
$FORM{$key} =~ s/>/\&gt;/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]

rainborick

5:16 pm on Jun 26, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I'm not a great Perl coder, but three things caught my eye that might help.

(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!

rocknbil

5:54 pm on Jun 26, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yes, no need to read/parse if use CGI; is included.

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">

Chico_Loco

2:42 am on Jun 28, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm not sure of the market rates to tell you the truth. When I need to do something in PERL, I generally do it myself - but judging by how much work would be involved (at a guess), I would think the bits to create an upload part could be salvaged from other free scripts - so $80 seems a little out of shape from my perspective. I have no idea why programmers are so expensive still, since there are so many they should be a dime a dozzen.. few more years I guess!

webmstr

3:20 am on Jun 28, 2005 (gmt 0)

10+ Year Member



well, due to time contraints I went ahead and let them do the script. The company I am building the site for was more than happy to pay extra for it, so that is a plus. I hate tacking on fees after the fact, so I now know to make sure I get that going in the quote. They wrote an entirely new script and did a beautiful job. It all works perfectly and I am very happy. I think it was worth it just to not have the headache. Thanks for you input! So interesting to learn about all the different aspects of this business!