F
froil
When i run the script below the output looks good, but the file that is
uploaded is 0 bytes. If anyone can help me find out why the file is
empty that would be awesome.
the script is passed the values of
filename and description through a web form
www.jilesfamily.net/uploadtest.html using the encoding of
multipart/formdata.
#!/usr/bin/perl -wT
#uploadtest.cgi
use strict;
use CGI qw
standard);
use CGI::Carp qw(fatalsToBrowser);
$CGI:
OST_MAX = 1024 * 1000;
my $upload_dir =
"/hsphere/local/home/jilesfre/jilesfamily.net/uploads";
my $File_Name = param('filename');
if (!$File_Name && cgi_error()) {
print header(-status=>cgi_error());
exit 0;
}
my $description = param('description');
my $New_Name = Get_Full_Name($File_Name);
Store_Results();
Print_Results();
sub Print_Results{
print header;
print start_html('TEST Pictures');
print qq(<h1>Description: $description</h1>);
print qq(<h1> File Name: $File_Name</h1>);
print qq(<h1> New Name: $New_Name</h1>);
print end_html;
}
sub Store_Results{
my $data;
open (STORAGE, ">$upload_dir/$New_Name")
or die "Error: $upload_dir/$New_Name: $!\n";
binmode ($File_Name);
binmode (STORAGE);
while( read($File_Name, $data, 1024) ){
print STORAGE $data;
}
close STORAGE;
}
sub Get_Full_Name{
my $full_name = shift;
$full_name =~ s/.*[\/\\](.*)/$1/;
return($full_name);
}
uploaded is 0 bytes. If anyone can help me find out why the file is
empty that would be awesome.
the script is passed the values of
filename and description through a web form
www.jilesfamily.net/uploadtest.html using the encoding of
multipart/formdata.
#!/usr/bin/perl -wT
#uploadtest.cgi
use strict;
use CGI qw
use CGI::Carp qw(fatalsToBrowser);
$CGI:
my $upload_dir =
"/hsphere/local/home/jilesfre/jilesfamily.net/uploads";
my $File_Name = param('filename');
if (!$File_Name && cgi_error()) {
print header(-status=>cgi_error());
exit 0;
}
my $description = param('description');
my $New_Name = Get_Full_Name($File_Name);
Store_Results();
Print_Results();
sub Print_Results{
print header;
print start_html('TEST Pictures');
print qq(<h1>Description: $description</h1>);
print qq(<h1> File Name: $File_Name</h1>);
print qq(<h1> New Name: $New_Name</h1>);
print end_html;
}
sub Store_Results{
my $data;
open (STORAGE, ">$upload_dir/$New_Name")
or die "Error: $upload_dir/$New_Name: $!\n";
binmode ($File_Name);
binmode (STORAGE);
while( read($File_Name, $data, 1024) ){
print STORAGE $data;
}
close STORAGE;
}
sub Get_Full_Name{
my $full_name = shift;
$full_name =~ s/.*[\/\\](.*)/$1/;
return($full_name);
}