I'm using the drop event in JavaScript to upload files using the following code:
var fileName = event.dataTransfer.files[0].name;
var orgValue = document.getElementById('<%=tbfilesCollections.ClientID%>').value;
if (orgValue == 'undefined') {
orgValue = '';
}
orgValue += orgValue == '' ? '' : '\n';
orgValue += "*" + fileName;
document.getElementById('<%=tbfilesCollections.ClientID%>').value = orgValue;
event.preventDefault();
return false;
But this code only gets the file name... I need to get the full path of the file.
The ondragover event occurs when a draggable element or text selection is being dragged over a valid drop target. By default, data/elements cannot be dropped in other elements. To allow a drop, we must prevent the default handling of the element. This is done by calling the event.
The DragEvent interface is a DOM event that represents a drag and drop interaction. The user initiates a drag by placing a pointer device (such as a mouse) on the touch surface and then dragging the pointer to a new location (such as another DOM element).
As this post points out, you cannot get the full path as you would like: Javascript File Drop.
As mentioned in the comments by Michael Sandino, there is a way to do this in Firefox with the "mozFullPath" attribute, but I have yet to see a universally-implemented way of accomplishing this.
The reason for this I would imagine is that the browser shouldn't divulge information regarding the folder structure of a client computer to a web application, which is understandable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With