HTML::Object::DOM::FileList - HTML Object DOM FileList Class
use HTML::Object::DOM::FileList; my $list = HTML::Object::DOM::FileList->new || die( HTML::Object::DOM::FileList->error, "\n" ); <input id="fileItem" type="file" /> my $file = $doc->getElementById('fileItem')->files->[0];
v0.2.0
An object of this type is returned by the "files" in HTML::Object::DOM::Element::Input property of the HTML <input> element; this lets you access a list of files you would have set or added, removed, etc.. It inherits from Module::Generic::Array
<input
Normally, under JavaScript, those files are selected with the <input type="file" /> element. It is also used on the web for a list of files dropped into web content when using the drag and drop API; see the DataTransfer object on Mozilla for details on this usage.
<input type="file" /
Read-only.
Returns the number of files in the list.
Returns a HTML::Object::DOM::File object representing the file at the specified index in the file list.
Example:
# fileInput is an HTML input element: <input type="file" id="myfileinput" multiple /> my $fileInput = $doc->getElementById("myfileinput"); # files is a FileList object (similar to NodeList) my $files = $fileInput->files; my $file; # loop through files for( my $i = 0; $i < $files->length; $i++ ) { # get item $file = $files->item($i); # or $file = $files->[$i]; say( $file->name ); }
Jacques Deguest <jack@deguest.jp>
Mozilla documentation
Copyright(c) 2021 DEGUEST Pte. Ltd.
All rights reserved
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install HTML::Object, copy and paste the appropriate command in to your terminal.
cpanm
cpanm HTML::Object
CPAN shell
perl -MCPAN -e shell install HTML::Object
For more information on module installation, please visit the detailed CPAN module installation guide.