Hello!
I have written the below script for file uploading, but the script seems to
be a little fickle.
Very small text files upload with no problem at all, but slightly larger
(76k) Word docs and Excel spread sheets
seem to make the script time out. I can see the /tmp/CGIxxxxxx2768 type
files being created, but I still get a timeout.
Not sure if this has be hashed out and re-hashed out, so, I apologize if
this mail is trite.
FYI - I am calling this cgi from an html for which I pasted in below the
perl script.
Thanks for any help in advance!
-James
#----------Begin Perl Script------------------------#
#!/usr/bin/perl -w
use strict;
use CGI qw/:standard/;
use CGI::Carp qw(fatalsToBrowser);
$| =1;
# Create the CGI script....
my $cgi = new CGI;
# Set the upload directory...
my $dir = qq(/usr/local/apache/htdocs/nuke/intranet);
# Set the cgi param for the file name...
my $file = $cgi->param('file');
# Start of main body of program...
$file =~ m/^.*(\\|\/)(.*)/;
my $name = $2;
open LOCAL, ">$dir/$name" or die "Cannot open file for writing: $!\n";
my ($bytesread,$buffer);
while($bytesread=read($file,$buffer,1024)) {
print LOCAL $buffer;
}
close(LOCAL);
print $cgi->header();
print $cgi->start_html(
-title=>"Successful Upload",
-bgcolor=>"#000000",
-text=>"#FFFFFF",
-link=>'blue',
-vlink=>'blue'
);
print "$file has bee successfully uploaded ... thank you!\n";
print $cgi->br;
print "Go ";
print
$cgi->a({href=>"http://nuke.theashlandagency.com/intranet"},'here');
print "to view all files.";
print $cgi->br;
print "Go ";
print $cgi->a({href=>"http://nuke.theashlandagency.com/upload.html"},
'here');
print "to upload more files.";
print $cgi->end_html;
#---------End Perl Script---------------------#
#---------Begin HTML Form---------------------#
<html>
<head>
<title> File upload page </title>
</head>
<body bgcolor="#000000" text="#FFFFFF">
<div align="center">
<h2>File Upload section...</h2>
<form enctype="multipart/form-data" action="fileup.cgi" method="post">
Please select a file to upload: <br>
<input type="file" name="file"> <br>
<p>
<input type="submit">
</form>
</div>
</body>
</html>
#----------End HTML Form-----------------------------#
James Kelty
Sr. Unix Systems Administrator
The Ashland Agency
541.488.0801
[EMAIL PROTECTED]
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]