嗨即时通讯开发一个Web应用程序,其中包含选项文件upload.im使用jquery和通用处理程序做这件事。上传文件asyn使用jquery
这里是我的代码:
<script type = "text/javascript">
$(window).load(
function() {
$("#<%=FileUploadcom.ClientID %>").fileUpload ({
'uploader' : 'scripts/uploader.swf',
'cancelImg' : 'images/cancel.png',
'buttonText' : 'Browse Files',
'script' : 'Upload.ashx',
'folder': 'uploads',
'fileDesc' : 'Image Files',
'fileExt' : '*.jpg;*.jpeg;*.gif;*.png',
'multi' : true,
'auto': true
});
}
);
</script>
和
<div>
<asp:FileUpload ID="FileUploadcom" runat="server" />
</div>
在不久的每一行:预计我得到错误的';'。如果我将其替换为:在执行时获取错误为XML分析错误:找不到元素。 任何人都可以帮助我使上述脚本完美工作。
我一般的处理程序代码:
<%@ WebHandler Language="C#" Class="Upload" %>
using System;
using System.Web;
using System.IO;
public class Upload : IHttpHandler {
public void ProcessRequest (HttpContext context) {
context.Response.ContentType = "text/plain";
context.Response.Expires = -1;
try
{
HttpPostedFile postedFile = context.Request.Files["Filedata"];
string savepath = "";
string tempPath = "";
tempPath = System.Configuration.ConfigurationManager.AppSettings["FolderPathN"];
savepath = context.Server.MapPath(tempPath);
string filename = postedFile.FileName;
if (!Directory.Exists(savepath))
Directory.CreateDirectory(savepath);
postedFile.SaveAs(savepath + @"\" + filename);
context.Response.Write(tempPath + "/" + filename);
context.Response.StatusCode = 200;
}
catch (Exception ex)
{
context.Response.Write("Error: " + ex.Message);
}
}
public bool IsReusable {
get {
return false;
}
}
}
如果我评论的scrit形式打开,如果我未收到意见如下 错误:
在此先感谢。
'$( “#<%= FileUploadcom.ClientID%>”)。文件上传({'开括号失踪 – 2014-09-20 11:49:10
你的脚本有不正确的语法.'' $(窗口).load(函数(){ $ .fileUpload({})});'' – Hamix 2014-09-20 11:52:14
感谢您的快速响应...缺少括号???让我检查 – Appdev 2014-09-20 11:54:25