Firefox 3.6 introduced a [multiple attribute on regular type=\"file\" input elements]( http://hacks.mozilla.org/2009/12/multiple-file-input-in-firefox-3-6/).
I canno
Woohoo, got this working. The big handbrake issue? Old CGI.pm version! It's a shame the CGI.pm documentation does not include notes alongside features such as "Introduced in version X". Many other modules/libraries/packages do.
As it happens I had version 3.15 and the current is 3.49. I even got it working in strict mode. Anybody know why Stein uses non-strict examples?
Here's the XHTML:
Multiple file upload test
Here's the Perl:
#!/usr/bin/perl
use strict;
use warnings;
use CGI;
my $CGIo = new CGI;
print $CGIo->header();
my @lightweight_fh = $CGIo->upload('multiple_files');
foreach my $fh (@lightweight_fh) {
# undef may be returned if it's not a valid file handle
if (defined $fh) {
# Upgrade the handle to one compatible with IO::Handle:
my $io_handle = $fh->handle;
open (OUTFILE,'>>','/deliberately_hidden/' . $fh);
while (my $bytesread = $io_handle->read(my $buffer,1024)) {
print OUTFILE $buffer
}
}
}
Thanks for your help everyone.