单击上载按钮后,AjaxFileUpload显示红色错误 [英] AjaxFileUpload displaying Red error after Upload button clicked
本文介绍了单击上载按钮后,AjaxFileUpload显示红色错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我遇到了能够拖放图片的 AjaxFileUpload
的问题。点击上传后,文件不会上传,并在文件旁边显示红色的错误消息。
非常感谢,如果有人可以提供解决方案。
下面是我的代码片段。
.aspx page
< ajaxToolkit:AjaxFileUpload
id = ajaxUpload1
önUploadComplete = ajaxUpload1_OnUploadComplete
ThrobberID = MyThrobber
MaximumNumberOfFiles = < span class =code-keyword> 1
< span class =code-attribute> AllowedFileTypes = jpg,jpeg,gif,png
< span class =code-attribute> runat = server / >
< asp:图像
id = MyThrobber
< span class =code-attribute> ImageUrl = 〜/ images / ajax-loader.gif
样式 = display:None
runat = server / >
.cs
受保护 void ajaxUpload1_OnUploadComplete( object sender,AjaxControlToolkit.AjaxFileUploadEventArgs e)
{
// 生成文件路径
string filePath = 〜/ images / + e.FileName;
// 将上传文件保存到文件系统
ajaxUpload1 .SaveAs(MapPath的(文件路径));
}
解决方案
将以下内容添加到您的web.config中:
< system.webServer >
< 处理程序 >
< add 名称 = < span class =code-keyword> AjaxFileUploadHandler 动词 = * 路径 = AjaxFileUploadHandler.axd type = AjaxControlToolkit.AjaxFileUploadHandler,AjaxControlToolkit / >
< / handlers >
< / system.webServer > 跨度>
Hi,
I am having problem with the AjaxFileUpload
that enables dragging and dropping of images. Upon clicking "Upload" the file does not upload and shows a red "error" message by the side of the file.
Would greatly appreciate, if someone can provide the solution to it.
Below is a snippet of my code.
.aspx page
<ajaxToolkit:AjaxFileUpload
id="ajaxUpload1"
önUploadComplete="ajaxUpload1_OnUploadComplete"
ThrobberID="MyThrobber"
MaximumNumberOfFiles="1"
AllowedFileTypes="jpg,jpeg,gif,png"
runat="server" />
<asp:Image
id="MyThrobber"
ImageUrl="~/images/ajax-loader.gif"
Style="display:None"
runat="server" />
.cs
protected void ajaxUpload1_OnUploadComplete(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e)
{
// Generate file path
string filePath = "~/images/" + e.FileName;
// Save upload file to the file system
ajaxUpload1.SaveAs(MapPath(filePath));
}
解决方案
Add the following to your web.config:
<system.webServer> <handlers> <add name="AjaxFileUploadHandler" verb="*" path="AjaxFileUploadHandler.axd" type="AjaxControlToolkit.AjaxFileUploadHandler, AjaxControlToolkit" /> </handlers> </system.webServer>
这篇关于单击上载按钮后,AjaxFileUpload显示红色错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文