Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Using HTML5 Drag/Drop for uploads - Help!

1 view
Skip to first unread message

Jo...@still_learning.invalid

unread,
Apr 29, 2013, 9:53:33 PM4/29/13
to
I'm trying to use HTML5's drag-and-drop to upload a set of files using
Perl.

Manually selecting the files, all works well, because in the following
code, myFile0[] contains the array of file info passed to the script. If,
OTOH, I drag files to the target div, myFile0[] is empty, and no data is
submitted. How do I submit the file information using drag/drop?

Pertinent code:

HTML:
<input type='file' name='myFile0[]' id='myFile0' multiple='multiple'>
<div><img src='../mailbox1.jpg' id='filedrag'></div>

js - Add event listeners:
fileselect = document.getElementById("myFile0");
filedrag = document.getElementById("filedrag");
fileselect.addEventListener("change", FileSelectHandler, false);
filedrag.addEventListener("dragover", FileDragHover, false);
filedrag.addEventListener("dragleave", FileDragHover, false);
filedrag.addEventListener("drop", FileSelectHandler, false);
return false;

js - file handler:
e.stopPropagation();
e.preventDefault();
e.target.className = (e.type == "dragover" ? "hover" : "");

var files = e.target.files || e.dataTransfer.files;
(Files selected manually or drag/drop successfully make it to here)
Process files locally for listing, etc.
Submit HTML form to perl script

perl:
@uploadFiles = param('myFile0[]');
@upload_filehandles = $query->upload("myFile0[]");

print "$i uploadFiles:@uploadFiles<br>\n";
print "$i upload_filehandles:@upload_filehandles<br><br>\n";
exit 0;

TIA,
--
Joey

Jo...@still_learning.invalid

unread,
Apr 30, 2013, 3:27:52 PM4/30/13
to
Joey@still_Learning.invalid wrote:

>I'm trying to use HTML5's drag-and-drop to upload a set of files using
>Perl.
>
>Manually selecting the files, all works well, because in the following
>code, myFile0[] contains the array of file info passed to the script. If,
>OTOH, I drag files to the target div, myFile0[] is empty, and no data is
>submitted. How do I submit the file information using drag/drop?

What this reduces to is how to convey file handles to Perl.

Anyone?

Joey
0 new messages