嗨即時通訊開發一個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