¿Puede el CGI.pm de Perl procesar los campos de formulario <input type = "file", multiple = ""> de Firefox?
Firefox 3.6 introdujo un [atributo múltiple en elementos de entrada de tipo normal = "archivo"] (http://hacks.mozilla.org/2009/12/multiple-file-input-in-firefox-3-6/)
No puedo hacer que Perl procese estos campos. Puedo llamar al campo en un contexto de lista como este:
my @files = $CGIobject->param("File_Input");
Recorrer eso me dará los nombres de archivo como cadenas, pero nada más.
Cualquier sugerencia sería muy bienvenida.
Aquí está el HTML:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Multiple file upload test</title>
</head>
<body>
<form action="deliberately_obfuscated"
method="post"
enctype="multipart/form-data">
<input type="file"
name="multiple_files"
multiple="true"/>
<button type="submit">Submit</button>
</form>
</body>
</html>
Aquí está el Perl:
#!/usr/bin/perl
#use strict;
#use warnings;
use CGI;
my $CGIo = new CGI;
print $CGIo->header();
@lightweight_fh = $CGIo->upload('myfiles');
# undef may be returned
# if it's not a
# valid file handle
if (@lightweight_fh) {
# Upgrade the handle to
# one compatible with IO::Handle:
my $io_handle = $lightweight_fh->handle;
open (OUTFILE,'>>','/hidden_deliberately/');
while ($bytesread = $io_handle->read($buffer,1024)){
print OUTFILE $buffer;
}
}
El script no ingresa el
if (@lightweight_fh) {
bloquear.
He intentado Data: Dumper en @lightweight_fh antes del bloque if y literalmente no imprime absolutamente nada.