Drag & drop doesn't work in Edge browser if uploadMode=useForm. Switching uploadMode to other value make drag & drop working. Please refer plunker example. Is this a bug?
FileUploader doesn't support drag & drop in IE and Edge if uploadMode is useForm
Answers approved by DevExpress Support
Hello Denis,
Our developers have researched the issue and found out that it is related to IE directly: Input type=file" drag-and-drop IE
So, I am afraid we cannot fix the issue at the level of our widgets. I suggest you choose another uploadMode if you need to drag and drop in IE.
You can read more about this in the following thread:
T525318: dxFileUploader doesn't support drag & drop in IE 11 if uploadMode is useForm
Here is an online example:
https://jsfiddle.net/5ub6feza/
JavaScriptfunction dropHandler(event) {
doNothing(event);
var filelist = event.dataTransfer.files;
if (!filelist) return; // if null, exit now
var filecount = filelist.length; // get number of dropped files
if (filecount > 0) {
var fileInput = $("#file").dxFileUploader("instance");
fileInput.option("value", [event.dataTransfer.files[0]]);
var dropText = document.getElementById("dropText");
dropText.style.display = "none";
}
}
function doNothing(event) {
event.stopPropagation();
event.preventDefault();
}
$("#file").dxFileUploader({
uploadMode: 'useForm',
onContentReady: function() {
var dropArea = document.getElementById("dropContainer");
dropArea.addEventListener("drop", dropHandler, false);
dropArea.addEventListener("dragover", doNothing, false);
}
})
CSS.dx-fileuploader-input-label {
visibility: hidden
}
.dx-fileuploader{
width: 120px;
float: left;
}
#dropText{
padding-top: 23px;
}
#dropContainer{
border:1px solid black;
height:170px;
}
Please follow this Plunker example to see how drag&drop can work in Edge in your FileUploader component
Denis,
I do not see the <form> element in your example. The "useForm" upload mode requires the form. If it is absent, it is possible that you do not need the "useForm" upload mode. Would you please clarify this.
I have also attached a project with a screencast that illustrates that sending the uploaded data does not work with custom dragging. Please check it.
I also made some research on the possibilities with file upload and Drag&Drop.
Please allow me to add some comments.
While it's true that in the meantime Microsofts Edge browser is capable of Drag&Drop to insert files in a web site with some JavaScript code. But nevertheless it's impossible to submit those files through a web form to the server by using the simple input type file.
What I've found out so far is that this restriction is for security reasons. The file collection of the input element is read-only.
While other browsers may support this feature (like Chrome or Firefox) - Edge and IE do not.
Denis' sample is very good but it only shows how to implement Dragging files in a web page. The files are not sent to the server. The only way to the upload is by using Ajax calls.
But I didn't want to use Ajax because of the user experience. I'd like to submit any attachments along with the form submit and save everything together. From the user's perspective it's not very intuitive to click two buttons - one for entered data and the other to upload files. So I ended up to not support Drag&Drop.
Regards
Sven
Hello Denis,
Thank you for providing us with the online example. I have reproduced the issue and passed this ticket to our developers for further research.