Thursday, April 15th, 2010
Drag and drop file uploads in Gmail using just the specs
Category: Browsers, JavaScript
Gmail started off with the awful
input type="file"
"add more" typical solution that we all know and love. Then they added the ability to select multiple files via Flash.... and now they allow the ability to drag and drop files right onto the message compose using HTML5 standards.
Want to do it too? Check out the APIs and how you can do it all, including showing the thumbnails:
JAVASCRIPT:
function handleFiles(files) { for (var i = 0; i <files.length; i++) { var file = files[i]; var imageType = /image.*/;
if (!file.type.match(imageType)) { continue; }
var img = document.createElement("img"); img.classList.add("obj"); img.file = file; preview.appendChild(img);
var reader = new FileReader(); reader.onload = (function(aImg) { return function(e) { aImg.src = e.target.result; }; })(img); reader.readAsDataURL(file); } }
Posted by Dion Almaer at 7:17 pm
5 Comments-->4.5 rating from 17 votes
Friday, April 16, 2010
Drag and drop file uploads in Gmail using just the specs
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.