K
Koms Bomb
Environment: Win2000 professional, Apache 2.0, Perl 5.8, CGI.pm
I write and test my script on Win2K but I hope my script will be platform
independent.
The code is,
#!d:/perl/bin/perl.exe
use strict;
use warnings;
use CGI;
use MIME::Lite;
use File::Copy;
[snip]
my $fn = $cgi->param('screenshot'); #here $fn is the path of my client side!
if(defined $fn) {
$fn =~ s/.*[\/\\](.*)/$1/;
my $fh = $cgi->upload('screenshot');
binmode($fh);
copy($fh, './' . $fn);
print $fn;
#attach the file to mail message.
$msg->attach(Type =>'image/gif',
Path =>$fn,
Filename =>'./' . $fn
);
}
'screenshot' is the field name of fileupload, in html,
<td><input type="file" name="screenshot"
enctype='multipart/form-data'></td>.
I saw $fn is my client side file name, eg, if I select e:\temp\x.zip,
$fn is e:\temp\x.zip, not relate to any Apache environment. That is
obviously wrong.
My script works find except I can't upload file.
I've googled sample code for file uploading, but they can't work on my
system too.
I'm not good at Perl, and I don't know whether the error is due to my script
or
due to Apache/Win2K.
Any suggestion or anyone can give some sample code that can work on
Apache/Win2K ?
I write and test my script on Win2K but I hope my script will be platform
independent.
The code is,
#!d:/perl/bin/perl.exe
use strict;
use warnings;
use CGI;
use MIME::Lite;
use File::Copy;
[snip]
my $fn = $cgi->param('screenshot'); #here $fn is the path of my client side!
if(defined $fn) {
$fn =~ s/.*[\/\\](.*)/$1/;
my $fh = $cgi->upload('screenshot');
binmode($fh);
copy($fh, './' . $fn);
print $fn;
#attach the file to mail message.
$msg->attach(Type =>'image/gif',
Path =>$fn,
Filename =>'./' . $fn
);
}
'screenshot' is the field name of fileupload, in html,
<td><input type="file" name="screenshot"
enctype='multipart/form-data'></td>.
I saw $fn is my client side file name, eg, if I select e:\temp\x.zip,
$fn is e:\temp\x.zip, not relate to any Apache environment. That is
obviously wrong.
My script works find except I can't upload file.
I've googled sample code for file uploading, but they can't work on my
system too.
I'm not good at Perl, and I don't know whether the error is due to my script
or
due to Apache/Win2K.
Any suggestion or anyone can give some sample code that can work on
Apache/Win2K ?