AjaxfileUpload错误 [英] AjaxfileUpload error
问题描述
我想实现一个简单的ajaxtoolkit FileUpload控件和我点击上传每一次我得到的是一个错误。我试着将断点在AjaxFileUpload1_UploadComplete的功能,但它甚至不会被解雇。(也许是因为上传不完整了吗?)我应该怎么办,使其工作?
这里的错误:
这里是我的aspx:
<形式ID = form1的=服务器>
< DIV>
< ASP:的ScriptManager ID =ScriptManager1=服务器>
< / ASP:ScriptManager的>
< ASP:AjaxFileUpload ID =AjaxFileUpload1=服务器
onuploadcomplete =AjaxFileUpload1_UploadCompleteThrobberID =myThrobberMaximumNumberOfFiles =10AllowedFileTypes =JPG,JPEG/ >
< / DIV>
< /表及GT;
这里是funcion背后:
保护无效AjaxFileUpload1_UploadComplete(对象发件人,AjaxControlToolkit.AjaxFileUploadEventArgs E)
{
字符串ID =038191904;
Directory.CreateDirectory(使用Server.Mappath(〜/ App_Data文件/+身份证+/ scanned_docs /));
字符串文件路径=〜/ Member_Data /+身份证+/图片/;
路径字符串=文件路径+ e.FileName;
AjaxFileUpload1.SaveAs(使用Server.Mappath(文件路径)+ e.FileName);
//db1.insert_pic_slide(id,路径);
}
这是发生在我身上,我做了两件事情来解决它:
1)更新您的网站的web.config文件包含以下条目
<&的System.Web GT;
<&HttpHandlers的GT;
<添加动词=*路径=AjaxFileUploadHandler.axdTYPE =AjaxControlToolkit.AjaxFileUploadHandler,AjaxControlToolkit/>
< / HttpHandlers的>
< /system.web>
< system.webServer>
<&处理GT;
<添加名称=AjaxFileUploadHandler动词=*路径=AjaxFileUploadHandler.axdTYPE =AjaxControlToolkit.AjaxFileUploadHandler,AjaxControlToolkit/>
< /处理器>
< /system.webServer>
2)如果您是从上传页面是一个文件夹内与它自己的web.config文件与拒绝匿名授权规则,一定要添加一个允许AjaxFileUploadHandler像这样:
<位置路径=AjaxFileUploadHandler.axd>
<&的System.Web GT;
<授权>
<让用户=*/>
< /授权>
< /system.web>
< /地点>
I'm trying to implement a simple ajaxtoolkit fileupload control and every time I click "Upload" all I get is an error. I tried placing breakpoint in the "AjaxFileUpload1_UploadComplete" function but it won't even get fired.. (maybe because upload isn't complete yet?) what should I do to make it work?
here is the error:
here is my aspx:
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:AjaxFileUpload ID="AjaxFileUpload1" runat="server"
onuploadcomplete="AjaxFileUpload1_UploadComplete" ThrobberID="myThrobber" MaximumNumberOfFiles="10" AllowedFileTypes="jpg,jpeg"/>
</div>
</form>
and here is the funcion behind:
protected void AjaxFileUpload1_UploadComplete(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e)
{
string id = "038191904";
Directory.CreateDirectory(Server.MapPath("~/App_Data/" + id + "/scanned_docs/"));
string filePath = "~/Member_Data/" + id + "/images/";
string path = filePath + e.FileName;
AjaxFileUpload1.SaveAs(Server.MapPath(filePath) + e.FileName);
//db1.insert_pic_slide(id, path);
}
This was happening to me, and I did two things to fix it:
1) Update your site's web.config file to contain entries for the following:
<system.web>
<httpHandlers>
<add verb="*" path="AjaxFileUploadHandler.axd" type="AjaxControlToolkit.AjaxFileUploadHandler, AjaxControlToolkit" />
</httpHandlers>
</system.web>
<system.webServer>
<handlers>
<add name="AjaxFileUploadHandler" verb="*" path="AjaxFileUploadHandler.axd" type="AjaxControlToolkit.AjaxFileUploadHandler, AjaxControlToolkit" />
</handlers>
</system.webServer>
2) If the page you're uploading from is inside a folder with it's own web.config with deny anonymous authorization rules, make sure you add an allow for the AjaxFileUploadHandler like so:
<location path="AjaxFileUploadHandler.axd">
<system.web>
<authorization>
<allow users="*"/>
</authorization>
</system.web>
</location>
这篇关于AjaxfileUpload错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!