如何为 DotNetNuke 使用 Aquantum 多文件上传器(Jquery 插件)?
我正在尝试在 DotNetNuke 中使用 Aquantum 多个文件上传,但我无法让它工作。显然是因为我无法设置表单标签。
有谁知道如何在不使用 form 标签的情况下实现 pling ?
例如: 示例显示以下内容:
<form id="file_upload" class="file_upload" runat="server">
<div id = "filediv">
<input type="file" name="file" multiple>
<button>Upload</button>
<div>Upload files</div>
</div>
<table id="files"></table> ...
</form>
但我希望能够执行以下操作:
<div id="file_upload" class="file_upload" runat="server">
<div id = "filediv">
<input type="file" name="file" multiple>
<button>Upload</button>
<div>Upload files</div>
</div>
<table id="files"></table> ...
</div>
我正在使用的 Javascript 是这个:
<script>
/*global $ */
$(function() {
$('.file_upload').fileUploadUI({
url: 'FileUpload.ashx',
method: 'POST',
uploadTable: $('#files'),
downloadTable: $('#files'),
buildUploadRow: function (files, index) {
return $('<tr><td>' + files[index].name + '<\/td>' +
'<td class="file_upload_progress"><div><\/div><\/td>' +
'<\/td><\/tr>');
},
buildDownloadRow: function(file) {
return $('<tr id="file_'+file.name+'"><td>' + file.name + '<\/td>'
+ '<td class="file_uploaded">' +
'<span class="ui-icon ui-icon-check"><\/span>' +
'<\/td><\/tr>');
}, beforeSend: function(event, files, index, xhr, handler, callBack) {
if (files[index].size > 500000) {
handler.uploadRow.find('.file_upload_progress').html('<span class="ui-icon ui-icon-alert"><\/span>FILE TOO BIG!');
setTimeout(function() {
handler.removeNode(handler.uploadRow);
}, 10000);
return;
}
callBack();
}
});
});
</script>
谢谢!欢迎任何帮助!
I'm trying to use Aquantum Multiple File Upload in DotNetNuke, but I cannot get it working. Aparently is because I cannot set the form tag.
Does anybody know how to implement the pluing without using the form tag?
Eg: Samples shows the following:
<form id="file_upload" class="file_upload" runat="server">
<div id = "filediv">
<input type="file" name="file" multiple>
<button>Upload</button>
<div>Upload files</div>
</div>
<table id="files"></table> ...
</form>
But I would like to be able to do the following:
<div id="file_upload" class="file_upload" runat="server">
<div id = "filediv">
<input type="file" name="file" multiple>
<button>Upload</button>
<div>Upload files</div>
</div>
<table id="files"></table> ...
</div>
The Javascript I'm using is this one:
<script>
/*global $ */
$(function() {
$('.file_upload').fileUploadUI({
url: 'FileUpload.ashx',
method: 'POST',
uploadTable: $('#files'),
downloadTable: $('#files'),
buildUploadRow: function (files, index) {
return $('<tr><td>' + files[index].name + '<\/td>' +
'<td class="file_upload_progress"><div><\/div><\/td>' +
'<\/td><\/tr>');
},
buildDownloadRow: function(file) {
return $('<tr id="file_'+file.name+'"><td>' + file.name + '<\/td>'
+ '<td class="file_uploaded">' +
'<span class="ui-icon ui-icon-check"><\/span>' +
'<\/td><\/tr>');
}, beforeSend: function(event, files, index, xhr, handler, callBack) {
if (files[index].size > 500000) {
handler.uploadRow.find('.file_upload_progress').html('<span class="ui-icon ui-icon-alert"><\/span>FILE TOO BIG!');
setTimeout(function() {
handler.removeNode(handler.uploadRow);
}, 10000);
return;
}
callBack();
}
});
});
</script>
Thanks! Any help will be welcomed!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
查看文档,看起来需要使用
form
来支持 IE & 浏览器。 Opera,但 DNN 中唯一可用的表单
是主要的 WebForms 表单。您可能需要考虑将 FileUpload.ashx 行为移动到 web.config 中设置的 HttpHandler 中。然后,您可以在 DNN 之前处理请求(使用 jQuery 插件上的formData
选项向帖子添加某种标志,然后在处理程序中查找该标志)。查看您的代码,它似乎应该适用于其他浏览器。 文档中的第一个常见问题解答表示您只需要设置
url
、method
和fieldName
选项来解决支持它的浏览器的表单(因此您可以尝试设置fieldName
看看是否有帮助)。您看到什么问题?有 JavaScript 错误吗?您的 ASHX 处理程序是否被击中?
Looking at the documentation, it looks like you need to use a
form
to support IE & Opera, but the onlyform
available in DNN is the main WebForms one. You might want to consider moving your FileUpload.ashx behavior into an HttpHandler that is setup in the web.config. Then you can process the request before DNN does (add some sort of flag to the post using theformData
option on the jQuery plugin, then look for that in your handler).Looking at your code, it appears that it should work for the other browsers. The first FAQ in the documentation says that you just need to set
url
,method
, andfieldName
options to work around the form for browsers that support it (so you might try settingfieldName
and seeing if that helps).What problem are you seeing? Any JavaScript errors? Is your ASHX handler being hit at all?