作为文件上传操作的一部分,当我在Internet Explorer中进行拖放式交互时,我目前遇到很大困难。我的代码非常基本:
HTML:
<div style="margin-top: 5%;">
@using (Html.BeginForm("Export", "Home", FormMethod.Post, new { enctype = "multipart/form-data" }))
{
<div id="uploadArea" ondragover="allowDrop(event)" ondrop="drop(event)">
<input type="file" name="file" id="file"/>
<p>Drag your files here or click in this area</p>
</div>
<button type="submit">Upload</button>
}
<div id="validationArea">
@Html.DisplayFor(model => model.ValidationMessage, new { id = "validationMessage", style = "color: red;" })
</div>
</div>
JS:
$('form input').change(function() {
$('form p').text(this.files.length + " file(s) selected");
$('#uploadArea').css('background-color', '#fff');
});
此事件在Chrome和Firefox中触发就好了,但如果我点击了<#39;那么仅在IE中触发(基本上是拖拉下去的儿子!)。