Gypsy
02-21-2007, 12:44 PM
I have the following code which works but for one small problem...the file does not upload!
Any help would be appreciated as I've hit the wall on this.
Thanks in advance...
#!/usr/local/bin/perl -w
use CGI;
use CGI::Carp qw/fatalsToBrowser/;
$upload_dir = "http://www.bensonvt.com/$section";
$query = new CGI;
$filename = $query->param("photo");
$firstname = $query->param("firstname");
$lastname = $query->param("lastname");
$title = $query->param("title");
$date = $query->param("date");
$section = $query->param("section");
$location = $query->param("location");
$email_address = $query->param("email");
$filename =~ s/.*[\/\\](.*)/$1/;
$upload_filehandle = $query->upload("photo");
open UPLOADFILE, ">$upload_dir/$filename";
binmode UPLOADFILE;
while ( <$upload_filehandle> )
{
print UPLOADFILE;
}
close UPLOADFILE;
print $query->header ( );
print <<END_HTML;
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en-AU">
<head>
<title>Official Website of Benson Vermont - Photo Submission</title>
<META NAME="TITLE" CONTENT="Benson Vermont Official Website">
<META NAME="AUTHOR" CONTENT="Daniel Jason Britton">
<META NAME="OWNER" CONTENT="Town of Benson/Daniel Jason Britton">
<META NAME="SUBJECT" CONTENT="Benson Vermont">
<META NAME="RATING" CONTENT="GENERAL">
<META NAME="DESCRIPTION" CONTENT="Benson Vermont Official Website">
<META NAME="ABSTRACT" CONTENT="Benson Vermont Official Website">
<META NAME="KEYWORDS" CONTENT="Benson, Vermont, Burdock,Farming,Merchants,Camping,Deer,Hunting,Country Living,Real,Estate,Fish">
<META NAME="REVISIT-AFTER" CONTENT="2 DAYS">
<META NAME="LANGUAGE" CONTENT="EN">
<META NAME="COPYRIGHT" CONTENT="BandWIDTH">
<META name="robots" content="index, follow">
<META HTTP-EQUIV="REFRESH" CONTENT="1200">
<META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<META HTTP-EQUIV="Expires" CONTENT="0">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
<link rel="stylesheet" type="text/css" href="/css/html.css" media="screen, projection, tv " />
<link rel="stylesheet" type="text/css" href="/css/layout.css" media="screen, projection, tv" />
<link rel="stylesheet" type="text/css" href="/css/print.css" media="print" />
</head>
<body>
<!-- CONTENT: Holds all site content except for the footer. This is what causes the footer to stick to the bottom -->
<div id="content">
<!-- HEADER: Holds title, subtitle and header images -->
<div id="header">
<div id="title">
<h1>Benson Vermont</h1>
<h2>"...Just Over The Hill"</h2>
</div>
<img src="/images/farm.gif" height="100%" alt="right slice" class="right" background="white">
</div>
<!-- MAIN MENU: Top horizontal menu of the site. Use class="" to turn the current page tab on -->
<div id="mainMenu">
<ul class="FloatCenter">
<script language="JavaScript" src="jstemplate1.js"></script>
</ul>
</div>
<!-- PAGE CONTENT BEGINS: This is where you would define the columns (number, width and alignment) -->
<div id="page">
<!-- 100 percent width column, aligned to the left -->
<div class="width100 floatLeft leftColumn">
<center>
<h1><center>Thank You For Your Submission</h1><CENTER>
<P></P><B><font size=3>$firstname, the file <font face="engravers MT" color="red" size=5>$filename</font> has been uploaded.</font></B></P>
<img src="http://www.bensonvt.com/$section/$filename" border="0">
<P><B><font size=4>Title: $title</font></P>
<P><font size=3>Taken on $date at $location</B></font></P>
<P><font size=3>Submitted by $firstname $lastname (<a href="$email_address">$email_address)</a></B><br>
<P>Should it pass review, it will be placed online in the <font face="engravers MT" color="red">$section</font> section.
</B></font></P>
</CENTER>
</BODY>
</HTML>
END_HTML
Any help would be appreciated as I've hit the wall on this.
Thanks in advance...
#!/usr/local/bin/perl -w
use CGI;
use CGI::Carp qw/fatalsToBrowser/;
$upload_dir = "http://www.bensonvt.com/$section";
$query = new CGI;
$filename = $query->param("photo");
$firstname = $query->param("firstname");
$lastname = $query->param("lastname");
$title = $query->param("title");
$date = $query->param("date");
$section = $query->param("section");
$location = $query->param("location");
$email_address = $query->param("email");
$filename =~ s/.*[\/\\](.*)/$1/;
$upload_filehandle = $query->upload("photo");
open UPLOADFILE, ">$upload_dir/$filename";
binmode UPLOADFILE;
while ( <$upload_filehandle> )
{
print UPLOADFILE;
}
close UPLOADFILE;
print $query->header ( );
print <<END_HTML;
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en-AU">
<head>
<title>Official Website of Benson Vermont - Photo Submission</title>
<META NAME="TITLE" CONTENT="Benson Vermont Official Website">
<META NAME="AUTHOR" CONTENT="Daniel Jason Britton">
<META NAME="OWNER" CONTENT="Town of Benson/Daniel Jason Britton">
<META NAME="SUBJECT" CONTENT="Benson Vermont">
<META NAME="RATING" CONTENT="GENERAL">
<META NAME="DESCRIPTION" CONTENT="Benson Vermont Official Website">
<META NAME="ABSTRACT" CONTENT="Benson Vermont Official Website">
<META NAME="KEYWORDS" CONTENT="Benson, Vermont, Burdock,Farming,Merchants,Camping,Deer,Hunting,Country Living,Real,Estate,Fish">
<META NAME="REVISIT-AFTER" CONTENT="2 DAYS">
<META NAME="LANGUAGE" CONTENT="EN">
<META NAME="COPYRIGHT" CONTENT="BandWIDTH">
<META name="robots" content="index, follow">
<META HTTP-EQUIV="REFRESH" CONTENT="1200">
<META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<META HTTP-EQUIV="Expires" CONTENT="0">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
<link rel="stylesheet" type="text/css" href="/css/html.css" media="screen, projection, tv " />
<link rel="stylesheet" type="text/css" href="/css/layout.css" media="screen, projection, tv" />
<link rel="stylesheet" type="text/css" href="/css/print.css" media="print" />
</head>
<body>
<!-- CONTENT: Holds all site content except for the footer. This is what causes the footer to stick to the bottom -->
<div id="content">
<!-- HEADER: Holds title, subtitle and header images -->
<div id="header">
<div id="title">
<h1>Benson Vermont</h1>
<h2>"...Just Over The Hill"</h2>
</div>
<img src="/images/farm.gif" height="100%" alt="right slice" class="right" background="white">
</div>
<!-- MAIN MENU: Top horizontal menu of the site. Use class="" to turn the current page tab on -->
<div id="mainMenu">
<ul class="FloatCenter">
<script language="JavaScript" src="jstemplate1.js"></script>
</ul>
</div>
<!-- PAGE CONTENT BEGINS: This is where you would define the columns (number, width and alignment) -->
<div id="page">
<!-- 100 percent width column, aligned to the left -->
<div class="width100 floatLeft leftColumn">
<center>
<h1><center>Thank You For Your Submission</h1><CENTER>
<P></P><B><font size=3>$firstname, the file <font face="engravers MT" color="red" size=5>$filename</font> has been uploaded.</font></B></P>
<img src="http://www.bensonvt.com/$section/$filename" border="0">
<P><B><font size=4>Title: $title</font></P>
<P><font size=3>Taken on $date at $location</B></font></P>
<P><font size=3>Submitted by $firstname $lastname (<a href="$email_address">$email_address)</a></B><br>
<P>Should it pass review, it will be placed online in the <font face="engravers MT" color="red">$section</font> section.
</B></font></P>
</CENTER>
</BODY>
</HTML>
END_HTML