Drag and Drop files
- Sebastian Haugland
- Posts: 43
- Joined: Fri Sep 19, 2014
- Contact:
Hi See below - I found a script to drag and drop files but I miss the bit on how to attach the file as attachement - as you see its only promt the filename.... (and it does not work in iexplorer only chrome.)
<!DOCTYPE html>
<html>
<body>
<div id="file-drop" style="border:1px dashed black; height:300px; width:300px;">Drop files here!</div>
<script>
var file_drop = document.getElementById('file-drop');
file_drop.addEventListener(
'dragover',
function handleDragOver(evt) {
evt.stopPropagation()
evt.preventDefault()
evt.dataTransfer.dropEffect = 'copy'
},
false
)
file_drop.addEventListener(
'drop',
function(evt) {
evt.stopPropagation()
evt.preventDefault()
var files = evt.dataTransfer.files // FileList object.
var file = files[0] // File object.
var hh=prompt(file.name)
},
false
)
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
<div id="file-drop" style="border:1px dashed black; height:300px; width:300px;">Drop files here!</div>
<script>
var file_drop = document.getElementById('file-drop');
file_drop.addEventListener(
'dragover',
function handleDragOver(evt) {
evt.stopPropagation()
evt.preventDefault()
evt.dataTransfer.dropEffect = 'copy'
},
false
)
file_drop.addEventListener(
'drop',
function(evt) {
evt.stopPropagation()
evt.preventDefault()
var files = evt.dataTransfer.files // FileList object.
var file = files[0] // File object.
var hh=prompt(file.name)
},
false
)
</script>
</body>
</html>
- Sebastian Haugland
- Posts: 43
- Joined: Fri Sep 19, 2014
- Contact:
Anhy suggestions?
- Dmitry Kozlov
- Site Admin
- Posts: 1524
- Joined: Thu Jun 07, 2012
I guess this is the same topic:
viewtopic.php?f=4&t=122#p515
viewtopic.php?f=4&t=122#p515
-
- Information
-
Who is online
Users browsing this forum: No registered users and 3 guests