Uploaded File Empty but in correct folder with correct name
- From: "froil" <jiles@xxxxxxxxxxxxxxx>
- Date: 27 Feb 2006 18:59:07 -0800
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::POST_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);
}
.
- Follow-Ups:
- Re: Uploaded File Empty but in correct folder with correct name
- From: Gunnar Hjalmarsson
- Re: Uploaded File Empty but in correct folder with correct name
- From: Samwyse
- Re: Uploaded File Empty but in correct folder with correct name
- Prev by Date: Re: File::Find problem on windows+apache+activePerl
- Next by Date: Re: Import other perl files
- Previous by thread: Copy contents of reference
- Next by thread: Re: Uploaded File Empty but in correct folder with correct name
- Index(es):
Relevant Pages
|
|