Script Help

by "Michael Lessar" <rfd246(at)bigfoot.com>

 Date:  Sun, 21 Jan 2001 18:10:20 -0500
 To:  <hwg-basics(at)hwg.org>
  todo: View Thread, Original
Hello everybody.

I am banging my head on my screen trying to figure out why this won't work.

here is a snippet from the script.
-----------------------------------

elsif ($action eq 'SavePhoto') {

 my $User = param('User');
 my $SalesPerson = param('SalesPerson');
 my $StockNumber = param('StockNumber');
 my $Price = param('Price');
 my $Year = param('Year');
 my $Make = param('Make');
 my $Model = param('Model');
 my $Description = param('Description');

 my $file = param('upload');
 my $fileName = $file;
 $fileName =~ s!^.*(\\|\/)!!;
 if (!$fileName) {
  error("<p>No photo selected</p>");
 }
 open (OUTFILE, ">$basedir/$fileName");
 print "$basedir/$fileName<br>";
 while (read($file, $data, 1024)){
  print OUTFILE $data;
 }
 close OUTFILE;


SaveAuto($User,$SalesPerson,$Price,$StockNumber,$Year,$Make,$Model,$Descript
ion,$Photo);
}

-----------------------------------
end snippet

here is the form for it

begin snippet
-----------------------------------
 print "<table width=\"100%\" border=\"0\" cellpadding=\"5\"
cellspacing=\"0\">\n";
 print "<tr>\n";
 print "<td align=\"left\" valign=\"top\">\n";
 print "<form action=\"$ENV{'SCRIPT_NAME'}\" method=\"post\"
enctype=\"multipart/form-data\">\n";
 print "<input type=\"hidden\" name=\"action\" value=\"SavePhoto\">\n";
 print "<input type=\"hidden\" name=\"User\" value=\"$User\">\n";
 print "<input type=\"hidden\" name=\"SalesPerson\"
value=\"$SalesPerson\">\n";
 print "<input type=\"hidden\" name=\"StockNumber\"
value=\"$StockNumber\">\n";
 print "<input type=\"hidden\" name=\"Price\" value=\"$Price\">\n";
 print "<input type=\"hidden\" name=\"Year\" value=\"$Year\">\n";
 print "<input type=\"hidden\" name=\"Make\" value=\"$Make\">\n";
 print "<input type=\"hidden\" name=\"Model\" value=\"$Model\">\n";
 print "<input type=\"hidden\" name=\"Description\"
value=\"$Description\">\n";
 print "<p style=\"font-size:13px;\">To upload a picture of the vehicle,
select browse and locate<br>the picture on <u>your</u> computer.</p>\n";
 print "Vehicle Picture <input type=\"file\" name=\"upload\">\n";
 print "</td>\n";
 print "</tr>\n";
 print "<tr>\n";
 print "<td align=\"center\" valign=\"bottom\">\n";
 print "<br><input type=\"submit\" value=\"Save with Photo!\"
style=\"width:120px;color:green;\">\n";
 print "<input type=\"submit\" value=\"Back\" style=\"color:c00000;\">\n";
 print "</td>\n";
 print "</tr>\n";
 print "</table>\n";
 print "</form>\n";

-----------------------------------
end snippet

What happens is it creates a file of the $fileName in the correct directory,
however this file is emtpy.

whether it is a text file or a binary file.  As you can see from the script
I intend to use binary and the code will be added later to differentiate
between the 2 right now I can't get it to copy the file.

I'm also using in the script:

use CGI qw/:standard/;

any thoughts would be appreciated

Mike

HTML: hwg-basics mailing list archives, maintained by Webmasters @ IWA