I want to create a product in my web that have a name,price category and image but i dont know how to upload that image in web service.
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public void CreateEditProduct()
{
try
{
int? id = __helper.ToNullableInt(HttpContext.Current.Request.Form["Id"].ToString());
string name = HttpContext.Current.Request.Form["Name"].ToString();
int price = int.Parse(HttpContext.Current.Request.Form["Price"].ToString());
string image = HttpContext.Current.Request.Form["Image"].ToString();
int categoryId = int.Parse(HttpContext.Current.Request.Form["CategoryId"].ToString());
Service1Client wcfObj = new Service1Client();
product addedProduct = wcfObj.CreateEditProduct(id, name, price, image, categoryId);
Context.Response.StatusCode = (int)HttpStatusCode.SeeOther;
Context.Response.Write(JsonConvert.SerializeObject(addedProduct));
}
catch (Exception ex)
{
Context.Response.StatusCode = (int)HttpStatusCode.SeeOther;
Context.Response.Write(JsonConvert.SerializeObject(ex));
}
}