Link to home
Start Free TrialLog in
Avatar of dr34m3rs
dr34m3rs

asked on

Javascript, Drag and Drop to a textbox or div, read path to local file

I want a very simple function to read the local path to a file dropped into a textbox or div.

The easiest method for my technology would be to inject the local filename into the value of the textbox.

<div>
Drop Area<br>
<input type="textbox" value="" id="dropArea" onchange="readLocalFileName()">
</div>

<script type="text/javascript">
function readLocalFileName()
{
       alert(document.getElementById('dropArea').value);
       //the above should be the local filename of the dropped file
}
</script>

// thanks for any help ^_^
Avatar of Gurvinder Pal Singh
Gurvinder Pal Singh
Flag of India image

what is the value in your textbox once you drag and drop the file in that textbox?
Avatar of dr34m3rs
dr34m3rs

ASKER

I want the value to be the local filename of the dropped file to pass to the upload function
check this one
http://jsfiddle.net/jimschubert/DqcUg/

works only on html5 compliant browsers
I need it to be as flexible as possible, sadly.
ASKER CERTIFIED SOLUTION
Avatar of Gurvinder Pal Singh
Gurvinder Pal Singh
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Ok thanks, I'll check it out and post soon, have to do some things tomorrow, but maybe Friday.
Sadly there is not a simple solution. I'll tinker. Thanks for the help!!