Click here to Skip to main content
15,746,420 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
how to get reference of fileupload control in static webmethod
please help me out

my aspx page
<asp:FileUpload ID="fileuploadreceipt" runat="server" />

and code behind
[WebMethod(EnableSession = true)]
    [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
    public static string insertrow(string CMEX_ID, string CMED_ID, string CMET_TYPE_DESC, string CMED_EXP_DT, Int32 CMED_EXP_TYPE, string CMED_EXP_DESC, string CMED_EXP_QTY, string CMED_EXP_RATE, string CMED_EXP_AMT, string CMED_EXP_RCPT_FILE_NAME, string CMED_EXP_COMMENTS, string CMED_EXP_COMP_PAID,string CMED_UPD_USER)

        string physicalpath = string.Empty;
        if (CMED_EXP_RCPT_FILE_NAME != null)
            HttpPostedFile fileup = HttpContext.Current.Request.Files["fileuploadreceipt"];
            string Ext = Path.GetExtension(Convert.ToString(CMED_EXP_RCPT_FILE_NAME));
            string filename = Path.GetFileName(Convert.ToString(CMED_EXP_RCPT_FILE_NAME));
            physicalpath = filename.Replace(filename, "") + Guid.NewGuid().ToString() + Ext;
            fileup.SaveAs(HttpContext.Current.Server.MapPath(physicalpath + "~/Receipts/"));

but i am getting httppostedfile null please help me out.
Updated 7-Nov-13 9:23am
ridoy 7-Nov-13 15:03pm    
you need to tell us a little bit more and show what have you tried?
Member 10057465 7-Nov-13 15:17pm    
updated my question please help me out

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900