I am attempting to implement an upload script and having problems. I see from the apache::asp documentation (http://www.apache-asp.org/cgi.html) that the recommendation is to roll back to CGI v2.78. This is not an option in my case- I am locked into 3.43. I am hoping that somebody can offer suggestions on patching either apache::asp or CGI to get my script to function. I am adapting the upload script from here, and it looks pretty straight forward:
http://www.sitepoint.com/article/uploading-files-cgi-perl/
Unfortunately, when I run the script, I end up with an empty file on my server. I have edited CGI.pm to use an appropriate $CGITempFile::TMPDIRECTORY
Some other potentially relevant specs: Fedora 10, Apache/2.2.11 (Unix) mod_perl/2.0.4 Perl/v5.10.0
Also, as another potential clue, I found which attempting to debug that I seem to have an empty request object... If I try to read directly from request->Form I get the error:
Can't locate object method "request" via package "Apache" at /home/httpd/html-MBA/Users/InputForms/Me
taManager4.html line 93. <--> , /usr/local/lib/perl5/site_perl/5.10.0/Apache/ASP.pm line 1522
Also, when I attempt to test the upload script from http://www.apache-asp.org/eg/file_upload.asp on my own server, I again seem to be stymied by the missing request object.
Many thanks for assisting in sorting this issue out.
Andrew Koebrick
++++++++++++++
Problem script:
my $safe_filename_characters = "a-zA-Z0-9_.-";
my $upload_dir = "$ENV{DOCUMENT_ROOT}/$cfg->{DocumentStore}";
my $filename = $query->param("Identifier-upload");
if ( !$filename )
{
print $query->header ( );
print "There was a problem uploading your photo (try a smaller file).";
exit;
}
my ( $name, $path, $extension ) = fileparse ( $filename, '\..*' );
$filename = $name . $extension;
$filename =~ tr/ /_/;
$filename =~ s/[^$safe_filename_characters]//g;
if ( $filename =~ /^([$safe_filename_characters]+)$/ )
{
$filename = $1;
}
else
{
die "Filename contains invalid characters";
}
my $upload_filehandle = $query->upload("Identifier-upload");
print "Location $upload_dir/$filename";
open ( UPLOADFILE, ">/home/httpd/html-MBA/$filename" ) or die "$!";
binmode UPLOADFILE;
while ( <$upload_filehandle> )
{
print UPLOADFILE;
}
close UPLOADFILE;
http://www.sitepoint.com/article/uploading-files-cgi-perl/
Unfortunately, when I run the script, I end up with an empty file on my server. I have edited CGI.pm to use an appropriate $CGITempFile::TMPDIRECTORY
Some other potentially relevant specs: Fedora 10, Apache/2.2.11 (Unix) mod_perl/2.0.4 Perl/v5.10.0
Also, as another potential clue, I found which attempting to debug that I seem to have an empty request object... If I try to read directly from request->Form I get the error:
Can't locate object method "request" via package "Apache" at /home/httpd/html-MBA/Users/InputForms/Me
taManager4.html line 93. <--> , /usr/local/lib/perl5/site_perl/5.10.0/Apache/ASP.pm line 1522
Also, when I attempt to test the upload script from http://www.apache-asp.org/eg/file_upload.asp on my own server, I again seem to be stymied by the missing request object.
Many thanks for assisting in sorting this issue out.
Andrew Koebrick
++++++++++++++
Problem script:
my $safe_filename_characters = "a-zA-Z0-9_.-";
my $upload_dir = "$ENV{DOCUMENT_ROOT}/$cfg->{DocumentStore}";
my $filename = $query->param("Identifier-upload");
if ( !$filename )
{
print $query->header ( );
print "There was a problem uploading your photo (try a smaller file).";
exit;
}
my ( $name, $path, $extension ) = fileparse ( $filename, '\..*' );
$filename = $name . $extension;
$filename =~ tr/ /_/;
$filename =~ s/[^$safe_filename_characters]//g;
if ( $filename =~ /^([$safe_filename_characters]+)$/ )
{
$filename = $1;
}
else
{
die "Filename contains invalid characters";
}
my $upload_filehandle = $query->upload("Identifier-upload");
print "Location $upload_dir/$filename";
open ( UPLOADFILE, ">/home/httpd/html-MBA/$filename" ) or die "$!";
binmode UPLOADFILE;
while ( <$upload_filehandle> )
{
print UPLOADFILE;
}
close UPLOADFILE;