J
jiles
I get this error "Can't use an undefined value as a HASH reference at
uploadsingle.cgi line 44." when i run this script on the web server. i
can't figure out why, any help would be great. the whole script is
below.
#!/usr/bin/perl -Tw
# uploadsigle.cgi
use strict;
use DBI;
use File::Basename;
use CGI qwstandard);
use CGI::Carp qw(fatalsToBrowser);
my $Directory =
"/hsphere/local/home/jilesfre/jilesfamily.net/cgi-bin/pictures";
my $Url_Path = "cgi-bin/pictures";
my $File_Name = param('filename');
my $Description = param('description');
my $File = Get_File_Name($File_Name);
Store_Results();
Store_Description();
Print_Results();
sub Store_Description{
my $DBH = DBI->connect(
"DBI:mysql:jilesfr_pictures:69.6.255.192:3306", "jilesfr_pictures",
"upload" ) or die "Error: $DBI::errstr\n";
my $sth_insert =
$DBH->prepare( qq{INSERT INTO files (Description,
FileName) VALUES (?,?)} )
or die $DBH->errstr;
$sth_insert->execute($Description, $File);
$DBH->disconnect;
}
sub Get_File_Name{
if( $ENV{HTTP_USER_AGENT} =~ /win/i ){
fileparse_set_fstype("MSDOS");
}
elsif( $ENV{HTTP_USER_AGENT} =~ /mac/i ){
fileparse_set_fstype("MacOS");
}
my $full_name = shift;
$full_name = basename($full_name);
$full_name =~ s!\s!\_!g;
return($full_name);
}
sub Store_Results{
my $data;
my $mime = uploadInfo($File_Name)->{'Content-Type'};
open (STORAGE, ">$Directory/$File")
or die "Error: $Directory/$File: $!\n";
if($mime !~ /text/){
binmode (File_Name);
binmode (STORAGE);
}
while( read($File_Name, $data, 1024) ){
print STORAGE $data;
}
close STORAGE;
}
sub Print_Results{
my $link = "$Url_Path/$File";
print header;
print start_html("Example 3");
print qq(<pre>);
print qq(<b>File Sent:</b> $File_Name);
print qq(<b>File Name:</b> $File);
print qq(<b>Link to File:</b><a href="$link">$link</a>);
print qq(</pre>);
print end_html;
}
uploadsingle.cgi line 44." when i run this script on the web server. i
can't figure out why, any help would be great. the whole script is
below.
#!/usr/bin/perl -Tw
# uploadsigle.cgi
use strict;
use DBI;
use File::Basename;
use CGI qwstandard);
use CGI::Carp qw(fatalsToBrowser);
my $Directory =
"/hsphere/local/home/jilesfre/jilesfamily.net/cgi-bin/pictures";
my $Url_Path = "cgi-bin/pictures";
my $File_Name = param('filename');
my $Description = param('description');
my $File = Get_File_Name($File_Name);
Store_Results();
Store_Description();
Print_Results();
sub Store_Description{
my $DBH = DBI->connect(
"DBI:mysql:jilesfr_pictures:69.6.255.192:3306", "jilesfr_pictures",
"upload" ) or die "Error: $DBI::errstr\n";
my $sth_insert =
$DBH->prepare( qq{INSERT INTO files (Description,
FileName) VALUES (?,?)} )
or die $DBH->errstr;
$sth_insert->execute($Description, $File);
$DBH->disconnect;
}
sub Get_File_Name{
if( $ENV{HTTP_USER_AGENT} =~ /win/i ){
fileparse_set_fstype("MSDOS");
}
elsif( $ENV{HTTP_USER_AGENT} =~ /mac/i ){
fileparse_set_fstype("MacOS");
}
my $full_name = shift;
$full_name = basename($full_name);
$full_name =~ s!\s!\_!g;
return($full_name);
}
sub Store_Results{
my $data;
my $mime = uploadInfo($File_Name)->{'Content-Type'};
open (STORAGE, ">$Directory/$File")
or die "Error: $Directory/$File: $!\n";
if($mime !~ /text/){
binmode (File_Name);
binmode (STORAGE);
}
while( read($File_Name, $data, 1024) ){
print STORAGE $data;
}
close STORAGE;
}
sub Print_Results{
my $link = "$Url_Path/$File";
print header;
print start_html("Example 3");
print qq(<pre>);
print qq(<b>File Sent:</b> $File_Name);
print qq(<b>File Name:</b> $File);
print qq(<b>Link to File:</b><a href="$link">$link</a>);
print qq(</pre>);
print end_html;
}