html5 drag drop,javascript

I'm trying to setup HTML5 drag and drop using dataTransfer.getData (http://html5demos.com/drag-anything) which reads any text into drop window and use plupload (http://www.plupload.com) to save that data.

Current code:

if (getDataType.checked == false && e.dataTransfer.types) {

li.innerHTML = '

  • ';

[].forEach.call(e.dataTransfer.types, function (type) {

li.innerHTML += '

' + entities(e.dataTransfer.getData(type) + ' (content-type: ' + type + ')') + '';

if (e.dataTransfer.types == 'Files') {

li.innerHTML += '

' + entities(e.dataTransfer.getData(type) + ' (uploadable: ' + type + ')') + '';

}

});

li.innerHTML += '

';

} else {

// ... however, if we're IE, we don't have the .types property, so we'll just get the Text value

li.innerHTML = e.dataTransfer.getData('Text');

}

I need help taking the output of dataTransfer.getData to plupload and the dropzone knowing the difference between a file and snippet of text.

EDIT:

To add more context around what I've tried.

1. Use if statement to do something if the dropped items are files. This doesn't work because (I believe) the items have already been dropped and therefore can't be uploaded

2. Get dataTransfer.files but that doesn't store uploadable files and kills the on-the-fly writing of the snippet.

I think that the solution involves querying the dropped items at the beginning and then using plupload for the files and dataTransfer.getData for the snippets - problem is I don't know how to do this. Any help would be much appreciated.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值