1

我有一个 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; }
   }
}


}   

先感谢您

4

0 回答 0