472,796 Members | 1,449 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,796 software developers and data experts.

script carrying over file with no problem but not text

cassbiz
202 100+
Could use some help here.

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
  1. <form enctype="multipart/form-data" action="./cgi/upload.pl" method="post">
  2.  
  3. <table cellspacing="0" cellpadding="2" width="100%" border="0">
  4. <tr>
  5. <td colspan="2" align="center"><font face="verdana,arial,helvetica,geneva">Upload your company logo</td>
  6. </tr>
  7. <tr>
  8. <td colspan="2" align="center">
  9. <font face="Verdana, Arial, Helvetica, sans-serif">Select an Image to Upload</font>&nbsp;&nbsp;
  10. <input type="file" name="userfile" /></td>
  11. </tr>
  12. <tr>
  13. <td colspan="2" align="center">
  14. <font face="Verdana, Arial, Helvetica, sans-serif">Your Description Line 1</font>
  15. &nbsp;&nbsp;<input type="text" name="description1" size="30" value="" maxlength="20" /><br />
  16. <font face="Verdana, Arial, Helvetica, sans-serif">Your Description Line 2</font>
  17. &nbsp;&nbsp;<input type="text" name="description2" size="30" value="" maxlength="20" /></td>
  18. </tr>
  19. <tr>
  20. <td colspan=2 align="center"><input type="submit" value="Upload Logo and Continue to Step 2"> <input type="reset" value="Start Over"></td>
  21. </tr>
  22. <tr>
  23. <td colspan="2" align=center>
  24.  
  25. <table bordercolor="#ffcc00" cellspacing="0" cellpadding="3" border="2" width="450">
  26. <tr>
  27. <td align="center">
  28. <table border="0">
  29. <tr>
  30. <td align="center"><font face="Verdana, Arial, Helvetica, sans-serif"
  31. color="#00cc0c">
  32. The size of the image may not be more than 50 KB,<br />
  33. and the image must be a JPG or GIF image.</font>
  34. </td>
  35. </tr>
  36. </table>
  37. </td></tr></table>
  38. </td>
  39. </tr>
  40. </table></form>
  41.  
Here is the script
Expand|Select|Wrap|Line Numbers
  1. # Let's define our variables first off..
  2. $| = 1;
  3. $upath = "/custom/images1/"; #with trailing /
  4. $upath_url = "/custom/images1"; #no trailing /
  5. $uindex = "/custom/images1/temp/"; #with trailing /
  6. $uimagedir = "/custom/images/"; #with trailing /
  7. $underlay_front = "/custom/images/t_front.jpg";
  8. $underlay_back = "/custom/images/t_back.jpg";
  9. $tempfile = $upath . $ENV{'REMOTE_ADDR'};
  10. $nofileerror = "/custom/uploaderror.html";
  11. $reg_pl = "/custom/cgi/register.pl";
  12. $recipient = "webmaster\@yourweb.com";
  13. $subject = "Wicked T\'s";
  14. $required = "Name,email";
  15. $redirect = "/custom/up.html";
  16. $sitename = "Rourke\'s Wicked T\'s";
  17. $db_url = "/custom/data/registered_users.dat";
  18. $db_fields = "Name,email,Uploaded_Pic,shirt_style";
  19.  
  20.  
  21.  
  22. # The following reads in the CGI buffer, and writes it to a temporary file
  23. # which will be used later.
  24.  
  25. read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
  26. open (x,">$tempfile");
  27. print x $buffer;
  28. close (x);
  29.  
  30.  
  31. # Now, time to open the temporary file and process it!
  32. open (temp,$tempfile);
  33.  
  34.  
  35. # Gotta pull the MIME/multipart separator line out.. We'll keep the 15
  36. # digit number for later...
  37. $_ = <temp>;
  38. ($vernum) = /(\d+)/;
  39.  
  40.  
  41. # Next line of the file contains the filename in the format:
  42. #     filename="C:\windows\win.ini"
  43. # We'll just keep the part inside the quotes...
  44. $_ = <temp>;
  45. $filetemp = $1 if (/filename=\"(.*)\"/);
  46.  
  47.  
  48. # The filename currently has the full pathname to the file in it.. We
  49. # don't want that! .. First we grab the last word after the backslash (for
  50. # PC systems), then we're gunna grab the last word after the forward slash
  51. # (unix systems).. Don't worry, it works.
  52. @pathz = (split(/\\/,$filetemp));
  53. $filetempb = $pathz[$#pathz];
  54. @pathza = (split('/',$filetempb));
  55. $filename = $pathza[$#pathza];
  56.  
  57.  
  58. #------------------------------------------------------#
  59. # START: Filter to allow only GIF and JPG files and
  60. # less than 50K Size
  61. #------------------------------------------------------#
  62.  
  63. $extension = (split(/\./,$filename))[-1];
  64. if ($extension !~ /(gif|jpg)/i )        {
  65.  print "Content-Type: text/html\n\n";
  66.         print "<html>\n<title>Error!</title>\n";
  67.         print "<body bgcolor=\"\#ffffff\" text=\"\#000000\">\n";
  68.         print "<DIV ALIGN=CENTER><H4><FONT COLOR=RED>ERROR - FILE TYPE NOT ALLOWED\!</FONT></H4><P>\n";
  69.         print "You can only upload a jpg or gif file.<BR>\n";
  70.         print "<b>or</b><BR>\n";
  71.         print "This routine does not work with your version of Internet Explorer.<P>\n";
  72.         print "Press your browsers BACK button to try again.</DIV>";
  73.         print "</html>\n";
  74.         exit 0;
  75. }
  76.  
  77. if ($ENV{'CONTENT_LENGTH'} >= 50000) {
  78.         print "Content-Type: text/html\n\n";
  79.         print "<html>\n<title>File size is too large!</title>\n";
  80.         print "<body bgcolor=\"\#ffffff\" text=\"\#000000\">\n";
  81.         print "<DIV ALIGN=CENTER><H4><FONT COLOR=RED>ERROR - IT'S TOO BIG\!</FONT></H4><P>\n";
  82.         print "Sorry but you are not authorized to upload files over 50k.<br>\n";
  83.         print "Please only upload files less than 50k in size.<br><br>";
  84.         print "<FORM><INPUT TYPE=\"button\" NAME=\"back\" VALUE=\"Start Over\" onClick=\"history.go(-1)\"></FORM>\n";
  85.         print "</DIV></html>\n";
  86.         exit 0;
  87. }
  88.  
  89. #------------------------------------------------------#
  90. # END: Filter to allow only GIF and JPG files and
  91. # less than 50K Size
  92. #------------------------------------------------------#
  93.  
  94.  
  95. # And, if the filename is nothing, we'll clean everything up and give them
  96. # a pretty error message
  97. if ($filename eq "") {
  98.         print "Location: $nofileerror\n\n";
  99.         close(temp);
  100.         `rm $tempfile`;
  101.         }
  102.  
  103.  
  104. # Now that we know the name of the file, let's create it in our upload
  105. # directory..
  106. open (outfile, ">$upath$filename");
  107.  
  108.  
  109. # Now we don't care about the Content-type of this, so we'll pass that up
  110. $junk = <temp>;
  111. $junk = <temp>;
  112.  
  113.  
  114. # And we're gunna read/write all the lines of our file until we come to the
  115. # MIME-multipart separator, which we'll ignore.
  116. while (<temp>) {
  117.    if (!(/-{28,29}$vernum/)) {
  118.                 print outfile $_;
  119.                 }
  120.    }
  121.  
  122. # We're done with that.. Let's close things up and remove that temp file.
  123. close (temp);
  124. close (outfile);
  125. `rm $tempfile`;
  126.  
  127.  
  128. # And bust da HTML
  129.  
  130. print "Content-type: text/html\n\n";
  131. print <<"EOF";
  132.  
  133. <html>
  134. <head>
  135. <title>$sitename</title>
  136. </head>
  137. <BODY text="#000000" bgcolor="#ffffff" link="#0000ff" vlink="#0000ff" alink="#ff00ff">
  138.  
  139.  
  140. <FORM action="$reg_pl" method="post">
  141. <input type="hidden" name="subject" value="$subject">
  142. <input type="hidden" name="redirect" value="$redirect">
  143. <input type="hidden" name="required" value="$required">
  144. <input type="hidden" name="recipient" value="$recipient">
  145. <input type="hidden" name="Uploaded_Pic" value="$upath_url/$filename">
  146. <input type="hidden" name="append_db" value="$db_url">
  147. <input type="hidden" name="db_fields" value = "$db_fields">
  148. <input type="hidden" name="db_delimiter" value = "|">
  149.  
  150.  
  151. <TABLE border="0" cellspacing="0" cellpadding="0" width=500>
  152.  
  153. <TR>
  154. <TD align=center colspan=2><h1>Shirt Front</h1>
  155. <img src=$underlay_front width="450">
  156. <span style="position: absolute; left: 270; top: 155"><img src=$upath_url/$filename width="80"></span>
  157. </TD>
  158. </TR>
  159.  
  160.  
  161. <TR>
  162. <TD align=center colspan=2><h1>Shirt Back</h1>
  163. <img src=$underlay_back width="450">
  164. <span style="position: absolute; left: 165; top: 660"><img src=$upath_url/$filename width="200"></span>
  165. </TD>
  166. </TR>
  167. <tr>
  168. <td colspan="2" align="center">
  169. <font face="Verdana, Arial, Helvetica, sans-serif">Your Description Line 1</font>
  170. &nbsp;&nbsp;<input type="text" name="description1" size="30" value="$description1" maxlength="20" /><br />
  171. <font face="Verdana, Arial, Helvetica, sans-serif">Your Description Line 2</font>
  172. &nbsp;&nbsp;<input type="text" name="description2" size="30" value="$description2" maxlength="20" /></td>
  173. </tr>
  174. <TR>
  175. <TD align="right">Name: </TD>
  176. <TD align="left"><INPUT type="text" name="Name" size="40"></TD>
  177. </TR>
  178. <TR>
  179. <TD align="right">Email Address: </TD>
  180. <TD align="left"><INPUT type=text name="email" size=40></TD>
  181. </TR>
  182. <TR>
  183. <TD align="right">Your City: </TD>
  184. <TD align="left"><INPUT type=text size="40" name="City"></TD>
  185. </TR>
  186. <TR>
  187. <TD align="right">Comments: </TD>
  188. <TD align="left"><TEXTAREA name="Features" rows="5" cols="40" wrap=virtual></TEXTAREA></TD>
  189. </TR>
  190. <TR>
  191. <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>
  192. </TR>
  193. </TABLE>
  194. </FORM>
  195. </center>
  196.  
  197. </BODY>
  198. </html>
  199.  
  200.  
  201. EOF
  202.  
  203. ;
  204.  
Apr 27 '08 #1
4 2866
KevinADC
4,059 Expert 2GB
That is the oddest perl based CGI script I ever seen. That type of scripting would have been before even the cgi-lib module was written, which is more than 10 years ago. I would look at how you are parsing the temp file.
Apr 27 '08 #2
cassbiz
202 100+
Yeah the script is old, if you know of another script that uploads and displays an image along with text, I would appreciate the location of it.
Apr 28 '08 #3
KevinADC
4,059 Expert 2GB
Yeah the script is old, if you know of another script that uploads and displays an image along with text, I would appreciate the location of it.
If you know some perl you can adapt the script in this article I wrote. You will need to add the text fields you want to save along with the file. If you are totally unfamiliar with the CGI module you would want to read the CGI documentation.

http://bytes.com/forum/thread672398.html
Apr 28 '08 #4
cassbiz
202 100+
Thank you for sending me over to the 'help' file. Will get back to you if I have any problems.
Apr 28 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

36
by: Richard | last post by:
My employer currently pays me $1/hour when I carry a pager. I have to carry the pager every fourth week. The problem is that my employer insists that I be available when I'm carrying the pager. ...
23
by: Loony | last post by:
I have got a code like this in HTML section in ASP file which includes javascript file! The script works under MS IE but doesn't with Firefox! Can anybody tell me what is wrong? <HTML>...
1
by: buran | last post by:
Dear ASP.NET Programmers, I am carrying the input of a textbox via querystring. When I put the value of querstring in a label control, the line breaks are removed. The whole text is displayed as...
4
by: Matt | last post by:
I have the following in a page and I am trying to update a record on the next page but for some reason the form data is not carrying over. Any ideas why? <form name=nxtlupdate method=post...
19
by: thisis | last post by:
Hi All, i have this.asp page: <script type="text/vbscript"> Function myFunc(val1ok, val2ok) ' do something ok myFunc = " return something ok" End Function </script>
1
devonknows
by: devonknows | last post by:
Hi, im having trouble carrying variables across a form, ive looked on here and other sites but cant find anything that helps me, or i might not be searching for the right terms, so i though i would...
9
by: 8anos | last post by:
Hello, I am new at the community and newbie at programming :) As you may know rapidshare provides a perl script for linux, to upload files at their servers. You can find the original scripts at...
5
by: camphor | last post by:
hi, I have found an upload script in hotscripts and have implemented it into the website, I followed the installation steps to 'give write permissions to php on the upload folder (which is...
3
by: aRTx | last post by:
I have try a couple of time but does not work for me My files everytime are sortet by NAME. I want to Sort my files by Date-desc. Can anyone help me to do it? The Script <? /* ORIGJINALI
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.