Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dropzone.js Drag & Drop does not work in IE10

I have followed the tutorial Combine normal form with Dropzone (https://github.com/enyo/dropzone/wiki/Combine-normal-form-with-Dropzone) and the resulting page works perfectly in the latest version of Google Chrome.

But, when I test the same page in IE10 drag and drop does not work. The drop zone is clickable and I can upload the files to the server, thus the dropzone is initialized correctly. It is just the drag and drop feature that does not work.

When I try the demo on http://www.dropzonejs.com/ drag and drop works in IE10.

I have checked the IE internet options and everything is enabled and I also added the localhost to trusted sites.

This is my code:

<script src="~/Scripts/dropzone.js"></script>
<script type="text/javascript">
    Dropzone.options.dropzoneForm = {
        autoProcessQueue: false,
        uploadMultiple: true,
        parallelUploads: 100,
        maxFiles: 100,
        addRemoveLinks: true,
        createImageThumbnails: false,

        // The setting up of the dropzone
        init: function() {
            var myDropzone = this;

            // First change the button to actually tell Dropzone to process the queue.
            this.element.querySelector("button[type=submit]").addEventListener("click", function(e) {
                // Make sure that the form isn't actually being sent.
                e.preventDefault();
                e.stopPropagation();
                myDropzone.processQueue();
            });
        }
    };
</script>

<form action="~/FileUpload/SaveUploadedFiles" method="post" enctype="multipart/form-data" class="dropzone" id="dropzoneForm">
    <div class="dropzone-previews"></div>
    <button type="submit">Submit data and files!</button>
</form>

Of course, the stylesheet is also added to the page.

Have I missed some configuration or is this an issue with the browser?

like image 720
Fredrik A. Avatar asked Nov 05 '13 14:11

Fredrik A.


People also ask

How do I drag and drop files to upload?

Drag and drop file uploads happen when you drag one or more files from an underlying platform's file manager and drop them onto a web page for upload. A preview of the image indicates the upload has begun. Many JavaScript libraries create this type of drag and drop file upload feature with a few lines of code.

How does dropzone JS work?

Dropzone. js is 'a light weight JavaScript library that turns an HTML element into a "dropzone"'. Users can drag and drop a file onto an area of the page, uploading to a server. If you would like to read more how all of this works skim through the Dropzone.

How do you use useDropzone?

The useDropzone hook just binds the necessary handlers to create a drag 'n' drop zone. Use the getRootProps() fn to get the props required for drag 'n' drop and use them on any element. For click and keydown behavior, use the getInputProps() fn and use the returned props on an <input> .

What is drag and drop file?

HTML Drag and Drop interfaces enable web applications to drag and drop files on a web page. This document describes how an application can accept one or more files that are dragged from the underlying platform's file manager and dropped on a web page.


3 Answers

It turns out that drag and drop does not work when I access the page in debug mode from Visual Studio. If I access the page from a newly opened browser it works just fine.

According to the thread http://social.msdn.microsoft.com/Forums/silverlight/en-US/383198a9-dbb4-4f94-8713-484e5bacb14b/dragdrop-not-active-during-debugging?forum=silverlightdevtools this can happen if Visual Studio and IE is executed with different accounts/priviligies. In my case Visual Studio is running as Administrator.

Since I do not need to debug the client scripts on this page I will just open the site in a fresh IE when I test the page.

like image 127
Fredrik A. Avatar answered Oct 11 '22 15:10

Fredrik A.


You have to and in bundleconfig these lines of code

        // dropZone styles
        bundles.Add(new StyleBundle("~/Scripts/dropZone").Include(
                  "~/Scripts/dropzone/css/basic.css",
                  "~/Scripts/dropzone/css/dropzone.css"));

        // dropZone 
        bundles.Add(new ScriptBundle("~/Scripts/dropzone").Include(
                  "~/Scripts/dropzone/dropzone.js"));

be carefull of the script paths to match yours in your solution Very Important: (SOS) - The css must be first and then the js files as in example.

like image 41
K.Konstantinou Avatar answered Oct 11 '22 15:10

K.Konstantinou


Check your head section to see if you are forcing compatibility with an older version of IE. A developer set ours to IE=9 and caused 500 Internal Server Errors every time a file was uploaded in IE11.

like image 31
Kit Triforce Avatar answered Oct 11 '22 13:10

Kit Triforce