0
我有一個用於配置文件圖像上傳的AJAX文件上傳器。我想限制用戶上傳圖像高達102400字節only.How文件大小超過時顯示javascript錯誤消息。如何在asp.net中使用AJAXFile Uploader限制FileSize?
代碼:
protected void AjaxFileUpload1_UploadComplete(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e)
{
string workerfile = Session["LoginUserID"].ToString();
string strFileName = string.Empty;
string strFileType = string.Empty;
string path = string.Empty;
var folder = Server.MapPath("../worker/Uploads/" + workerfile);
if (!Directory.Exists(folder))
{
Directory.CreateDirectory(folder);
strFileName = DateTime.Now.ToString("MM-dd-yyyy_HHmmss");
strFileType = System.IO.Path.GetExtension(e.FileName).ToString().ToLower();
AjaxFileUpload1.SaveAs(Server.MapPath("../worker/Uploads/" + Session["LoginUserID"] + "/" + workerfile + "_img" + strFileType));
}
else
{
strFileName = DateTime.Now.ToString("MM-dd-yyyy_HHmmss");
strFileType = System.IO.Path.GetExtension(e.FileName).ToString().ToLower();
AjaxFileUpload1.SaveAs(Server.MapPath("../worker/Uploads/" + Session["LoginUserID"] + "/" + workerfile + "_img" + strFileType));
}
}
如何做任何想法? 幫助讚賞。