>I want to have this form post to an EmbPerl script that will accept the
>upload and put it into a file. I've done this sort of thing before in a Perl
>CGI script, but I need to do it in EmbPerl if at all possible.
Here's a code excerpt. Won't run as is, but should give you the
necessary info.
sub uploadFile {
my $this = shift;
my ($fdat, $fieldname, $path) = @_;
my $filename = $fdat->{$fieldname};
my $contenttype = $fdat->{"-$fieldname"}->{'Content-Type'};
my (@endings);
throw SWC::CMS::Error("No filename specified for upload") if (!$filename);
$filename =~ s/.*\\//; # stupid PC gives the full pathname
$filename =~ s|[/:]|_|g; # not necessarily malicious, could be a Mac
$path = $this->fullPath($path . '/' . $filename);
$this->verifyFileType($filename);
my $fh = $this->makeFile($path);
my ($buf, $len);
while ($len = read($fdat->{$fieldname}, $buf, 4096)) {
$fh->print($buf) || throw SWC::CMS::Error("Unable to write to
$path: $!");
}
throw SWC::CMS::Error("Error reading $fdat->{$fieldname}: $!") if
(!defined $len);
$fh->close() || throw SWC::CMS::Error("Error closing $path: $!");
}
--
Kee Hinckley - Somewhere.Com, LLC
http://consulting.somewhere.com/
I'm not sure which upsets me more: that people are so unwilling to accept
responsibility for their own actions, or that they are so eager to regulate
everyone else's.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]