Trying to set fileinput val from jquery drag file

I am trying to make a simple downloader where users drag and drop files from the desktop to a website element. I believe that I understood how, but I cannot get any information about the file. How can I set the value of input files from drag and drop? Here is the drag and drop code im im not sure if it is correct. The box does change color when it is outlined on top of it.

$(".droparea").bind({
  dragleave: function (e) {
                e.preventDefault();
            $(".droparea").css("backgroundColor","white");


            },
            drop: function (e) {
                e.preventDefault();
//something here to set the FileInput element val()
                           },
            dragenter: function (e) {
                e.preventDefault();
               $(".droparea").css("backgroundColor","Green");
            },
            dragover: function (e) {
                e.preventDefault();

            }
        });
+5
source share
2 answers

If you use HTML5, this is a great tutorial here . You can just convert them to jQuery, as it seems you are using jQuery for your example.

Hooray!

0
source

All Articles