【发布时间】:2011-07-28 16:49:59
【问题描述】:
我有一个可以上传单个和多个文件的 ASP.NET 4 工作上传代码。 一旦uploadify发送它们,我使用HttpHandler在服务器端处理上传。
我应该如何在 MVC 3 中解决这个问题?
我是否需要编写不同的操作来处理单个文件和多个文件的上传?
我只需要代码的结构,以便我可以在服务器上处理发布的文件。
这是我在 ASP.NET 4 中的代码:
$(function () {
$('#file_upload').uploadify({
'uploader': '/content/uploadify/uploadify.swf',
'script': '/content/uploadify/uploadimg.ashx', <<-- httphandler here
'scriptData': { 'auth': auth, 'sid': sid, 'aid': '', 'pid': 0, 'multi': 1 },
'cancelImg': '/content/uploadify/cancel.gif',
'folder': '/content/uploadify/uploads',
'auto': false,
'multi': true,
'queueSizeLimit': 10,
'sizeLimit': 2359296,
'fileExt': '*.jpg;*.jpeg',
'fileDesc': 'Photo Files ( .jpg )',
'displayData': 'speed',
'expressInstall': '/content/uploadify/expressInstall.swf',
'removeCompleted': false,
'wmode': 'transparent',
'hideButton': true,
'height': 33,
'width': 156
, 'onSelectOnce': function (event, data) { //code omitted }
, 'onError': function (e, fid, fo, eo) { //code omitted }
, 'onComplete': function (e, q, f, r, d) { //code omitted }
, 'onAllComplete': function (e, d) {
//code omitted
}
});
});
uploadimg.ashx:
public class uploadimg : IHttpHandler, IRequiresSessionState
{
public void ProcessRequest (HttpContext context)
{
//code omitted
}
}
【问题讨论】: