saving image as binaries and other data in table in

Last Reply on Apr 12, 2012 06:21 AM By shafiqkr

Posted on Apr 12, 2012 01:55 AM


i am using using C# ,Jquery ajax and webmethods to save data to is my sample code

get all control values here like

 var add = $("#txtaddress").val();

              type: "POST",
              url: "A.aspx/SaveDATA",
              data: "{'id':'" + id + "','CountryId':'" + Country + "','CityId':'" + City + "','Area':'" + Area + "','LM':'" + LM + "','Lat':'" + Lat + "','Lon':'" + Lon + "','add':'" + add + "','KW': '" + KW + "','cName': '" + companyName + "','pCode':'" + pCode + "','catId':'" + catId + "','isEdit':'FALSE','email':'" + email + "','url':'" + url + "'}",
              contentType: "application/json; charset=utf-8",
              dataType: "json",
              success: function (msg) {




This is working fine.Now i know that these are client side controls and we can not upload image as there is no form save this data and image is not possible here.i also know that there are some plugins that save image either on ifram or ashx file but they do not save data like above.

I need help here how to make a senareo where we can save both in one request to database?like i want if we define a function on file upload change and save its result in any html control...then will be easy to get.i want image and this data all in on webmethod function


thanks in advance

Posted on Apr 12, 2012 02:22 AM

In handler you can do

context.Session["File"] = bytes;

And in WebMethod you can access Session using

Byte[] bytes  = (Byte[])HttpContext.Current.Session["File"];


Posted on Apr 12, 2012 06:21 AM

Yes i am sure.

After search and i found the solution....just replace this code

public class MyHandler : IHttpHandler, System.Web.SessionState.IReadOnlySessionState

Here is link