Hi...
how to save Base64 value using web service in asp.net. following method am try plz check or guide me. am get base64 value but not insert into a database....??????????????????????????????
public static string InsertImg(string Id_,string Name_,string Title_ ,string Image_)
{
string msg = "";
SqlConnection SqlConn = new SqlConnection(ConfigurationManager.ConnectionStrings["test"].ToString());
SqlCommand ocmd = new SqlCommand("pr_CMS.Recent_News", SqlConn);
try
{
ocmd.CommandType = System.Data.CommandType.StoredProcedure;
ocmd.Parameters.Add("@Id", SqlDbType.Int, 20).Value = Id_;
ocmd.Parameters.Add("@Title", SqlDbType.VarChar, 20).Value = Name_;
ocmd.Parameters.Add("@Summary", SqlDbType.VarChar, 50).Value = Title_;
ocmd.Parameters.Add("@Image", SqlDbType.Image).Value = Convert.ToByte(Image_);
ocmd.CommandTimeout = 15;
ocmd.Connection.Open();
ocmd.ExecuteNonQuery();
ocmd.Connection.Close();
msg = "true";
}
catch(Exception ex)
{
}
}
}
--------------------Jquery code
var id_ = "";
var name_ = $('#txtname').val();
var title_ = $('#txttitle').val();
var img_ = $('.dropzone > img').attr('src');
var imgs_ = img_.replace(/^data:image\/\w+;base64,/, "");
// var imgss_ = encodeURIComponent(imgs_);
var obj = { Id_: "", Name_: name_, Title_: title_, Image_: imgs_ };
console.log(imgs_);
$.ajax(
{
type: "POST",
contentType: "application/json; charset=utf-8",
url: "default.aspx/InsertImg",
data: JSON.stringify(obj),
dataType: "json",
success: function (data) {
var obj1 = data.d;
if (obj1 == 'true')
{
$(".save - reset").val('');
unblockUISave();
}
else { unblockUIError(obj1); $('.txtSubmited').val(""); }
},
error: ServiceFailed
});