如何将图像文件传递给ashx也会出错?无法创建类型'uploader'

时间:2013-10-10 22:08:48

标签: c# asp.net ashx

我有一个aspx页面,iframe里面有一个iframe我有一个ascx页面

代码示例

<form action="uploader.ashx" id="frmUploadPhoto" runat="server" method="post" enctype="multipart/form-data">

        <div  style="height: 80px;"></div>
        <div >
            <asp:fileupload runat="server" cssclass="btnSml" id="uploadPhoto" width="155px" />            
            <asp:button runat="server" cssclass="btnSml" id="btnUploadPhoto" text="Upload" />

        </div>
    </form>

我的问题是,如何将数据传递给ashx控件,以便我可以保存文件?

public class UploadHandler : IHttpHandler
{
    public class Upload : IHttpHandler {
   public void ProcessRequest(HttpContext context) {         
     HttpPostedFile oFile = context.Request.Files["Filedata"];
     string sDirectory = HttpContext.Current.Server.MapPath("uploads");
     oFile.SaveAs(sDirectory + oFile.FileName);     
   }
   public bool IsReusable {
      get { return false; }
   }
}


}   

提前谢谢

0 个答案:

没有答案