This script is carrying over an image just fine but the text isn't coming over. can you see why it is not working????
from the form I want to carry over two lines of text and I can't find the error on why it isn't working.
Any help is greatly appreciated.
Here is the form
Expand|Select|Wrap|Line Numbers
- <form enctype="multipart/form-data" action="./cgi/upload.pl" method="post">
- <table cellspacing="0" cellpadding="2" width="100%" border="0">
- <tr>
- <td colspan="2" align="center"><font face="verdana,arial,helvetica,geneva">Upload your company logo</td>
- </tr>
- <tr>
- <td colspan="2" align="center">
- <font face="Verdana, Arial, Helvetica, sans-serif">Select an Image to Upload</font>
- <input type="file" name="userfile" /></td>
- </tr>
- <tr>
- <td colspan="2" align="center">
- <font face="Verdana, Arial, Helvetica, sans-serif">Your Description Line 1</font>
- <input type="text" name="description1" size="30" value="" maxlength="20" /><br />
- <font face="Verdana, Arial, Helvetica, sans-serif">Your Description Line 2</font>
- <input type="text" name="description2" size="30" value="" maxlength="20" /></td>
- </tr>
- <tr>
- <td colspan=2 align="center"><input type="submit" value="Upload Logo and Continue to Step 2"> <input type="reset" value="Start Over"></td>
- </tr>
- <tr>
- <td colspan="2" align=center>
- <table bordercolor="#ffcc00" cellspacing="0" cellpadding="3" border="2" width="450">
- <tr>
- <td align="center">
- <table border="0">
- <tr>
- <td align="center"><font face="Verdana, Arial, Helvetica, sans-serif"
- color="#00cc0c">
- The size of the image may not be more than 50 KB,<br />
- and the image must be a JPG or GIF image.</font>
- </td>
- </tr>
- </table>
- </td></tr></table>
- </td>
- </tr>
- </table></form>
Expand|Select|Wrap|Line Numbers
- # Let's define our variables first off..
- $| = 1;
- $upath = "/custom/images1/"; #with trailing /
- $upath_url = "/custom/images1"; #no trailing /
- $uindex = "/custom/images1/temp/"; #with trailing /
- $uimagedir = "/custom/images/"; #with trailing /
- $underlay_front = "/custom/images/t_front.jpg";
- $underlay_back = "/custom/images/t_back.jpg";
- $tempfile = $upath . $ENV{'REMOTE_ADDR'};
- $nofileerror = "/custom/uploaderror.html";
- $reg_pl = "/custom/cgi/register.pl";
- $recipient = "webmaster\@yourweb.com";
- $subject = "Wicked T\'s";
- $required = "Name,email";
- $redirect = "/custom/up.html";
- $sitename = "Rourke\'s Wicked T\'s";
- $db_url = "/custom/data/registered_users.dat";
- $db_fields = "Name,email,Uploaded_Pic,shirt_style";
- # The following reads in the CGI buffer, and writes it to a temporary file
- # which will be used later.
- read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
- open (x,">$tempfile");
- print x $buffer;
- close (x);
- # Now, time to open the temporary file and process it!
- open (temp,$tempfile);
- # Gotta pull the MIME/multipart separator line out.. We'll keep the 15
- # digit number for later...
- $_ = <temp>;
- ($vernum) = /(\d+)/;
- # Next line of the file contains the filename in the format:
- # filename="C:\windows\win.ini"
- # We'll just keep the part inside the quotes...
- $_ = <temp>;
- $filetemp = $1 if (/filename=\"(.*)\"/);
- # The filename currently has the full pathname to the file in it.. We
- # don't want that! .. First we grab the last word after the backslash (for
- # PC systems), then we're gunna grab the last word after the forward slash
- # (unix systems).. Don't worry, it works.
- @pathz = (split(/\\/,$filetemp));
- $filetempb = $pathz[$#pathz];
- @pathza = (split('/',$filetempb));
- $filename = $pathza[$#pathza];
- #------------------------------------------------------#
- # START: Filter to allow only GIF and JPG files and
- # less than 50K Size
- #------------------------------------------------------#
- $extension = (split(/\./,$filename))[-1];
- if ($extension !~ /(gif|jpg)/i ) {
- print "Content-Type: text/html\n\n";
- print "<html>\n<title>Error!</title>\n";
- print "<body bgcolor=\"\#ffffff\" text=\"\#000000\">\n";
- print "<DIV ALIGN=CENTER><H4><FONT COLOR=RED>ERROR - FILE TYPE NOT ALLOWED\!</FONT></H4><P>\n";
- print "You can only upload a jpg or gif file.<BR>\n";
- print "<b>or</b><BR>\n";
- print "This routine does not work with your version of Internet Explorer.<P>\n";
- print "Press your browsers BACK button to try again.</DIV>";
- print "</html>\n";
- exit 0;
- }
- if ($ENV{'CONTENT_LENGTH'} >= 50000) {
- print "Content-Type: text/html\n\n";
- print "<html>\n<title>File size is too large!</title>\n";
- print "<body bgcolor=\"\#ffffff\" text=\"\#000000\">\n";
- print "<DIV ALIGN=CENTER><H4><FONT COLOR=RED>ERROR - IT'S TOO BIG\!</FONT></H4><P>\n";
- print "Sorry but you are not authorized to upload files over 50k.<br>\n";
- print "Please only upload files less than 50k in size.<br><br>";
- print "<FORM><INPUT TYPE=\"button\" NAME=\"back\" VALUE=\"Start Over\" onClick=\"history.go(-1)\"></FORM>\n";
- print "</DIV></html>\n";
- exit 0;
- }
- #------------------------------------------------------#
- # END: Filter to allow only GIF and JPG files and
- # less than 50K Size
- #------------------------------------------------------#
- # And, if the filename is nothing, we'll clean everything up and give them
- # a pretty error message
- if ($filename eq "") {
- print "Location: $nofileerror\n\n";
- close(temp);
- `rm $tempfile`;
- }
- # Now that we know the name of the file, let's create it in our upload
- # directory..
- open (outfile, ">$upath$filename");
- # Now we don't care about the Content-type of this, so we'll pass that up
- $junk = <temp>;
- $junk = <temp>;
- # And we're gunna read/write all the lines of our file until we come to the
- # MIME-multipart separator, which we'll ignore.
- while (<temp>) {
- if (!(/-{28,29}$vernum/)) {
- print outfile $_;
- }
- }
- # We're done with that.. Let's close things up and remove that temp file.
- close (temp);
- close (outfile);
- `rm $tempfile`;
- # And bust da HTML
- print "Content-type: text/html\n\n";
- print <<"EOF";
- <html>
- <head>
- <title>$sitename</title>
- </head>
- <BODY text="#000000" bgcolor="#ffffff" link="#0000ff" vlink="#0000ff" alink="#ff00ff">
- <FORM action="$reg_pl" method="post">
- <input type="hidden" name="subject" value="$subject">
- <input type="hidden" name="redirect" value="$redirect">
- <input type="hidden" name="required" value="$required">
- <input type="hidden" name="recipient" value="$recipient">
- <input type="hidden" name="Uploaded_Pic" value="$upath_url/$filename">
- <input type="hidden" name="append_db" value="$db_url">
- <input type="hidden" name="db_fields" value = "$db_fields">
- <input type="hidden" name="db_delimiter" value = "|">
- <TABLE border="0" cellspacing="0" cellpadding="0" width=500>
- <TR>
- <TD align=center colspan=2><h1>Shirt Front</h1>
- <img src=$underlay_front width="450">
- <span style="position: absolute; left: 270; top: 155"><img src=$upath_url/$filename width="80"></span>
- </TD>
- </TR>
- <TR>
- <TD align=center colspan=2><h1>Shirt Back</h1>
- <img src=$underlay_back width="450">
- <span style="position: absolute; left: 165; top: 660"><img src=$upath_url/$filename width="200"></span>
- </TD>
- </TR>
- <tr>
- <td colspan="2" align="center">
- <font face="Verdana, Arial, Helvetica, sans-serif">Your Description Line 1</font>
- <input type="text" name="description1" size="30" value="$description1" maxlength="20" /><br />
- <font face="Verdana, Arial, Helvetica, sans-serif">Your Description Line 2</font>
- <input type="text" name="description2" size="30" value="$description2" maxlength="20" /></td>
- </tr>
- <TR>
- <TD align="right">Name: </TD>
- <TD align="left"><INPUT type="text" name="Name" size="40"></TD>
- </TR>
- <TR>
- <TD align="right">Email Address: </TD>
- <TD align="left"><INPUT type=text name="email" size=40></TD>
- </TR>
- <TR>
- <TD align="right">Your City: </TD>
- <TD align="left"><INPUT type=text size="40" name="City"></TD>
- </TR>
- <TR>
- <TD align="right">Comments: </TD>
- <TD align="left"><TEXTAREA name="Features" rows="5" cols="40" wrap=virtual></TEXTAREA></TD>
- </TR>
- <TR>
- <TD colspan=2 align=center><INPUT type="submit" value="Finish and Send Image"> <INPUT type="reset" value="Reset this Page"> <INPUT TYPE="button" NAME="back" VALUE="Start Over" onClick="history.go(-1)"></TD>
- </TR>
- </TABLE>
- </FORM>
- </center>
- </BODY>
- </html>
- EOF
- ;