TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Preetham Holenarasipuradevera
NA
75
12.2k
how to upload image to sql database
Mar 15 2021 2:11 AM
Hi everyone, i am developing a web api i want to upload image to sql database.
so far i know first i have to convert image in to byte array
i have created a coloum of type varbinary
model with data type byte[];
but when i pass the image from postman app IN object its showing null
Here i have attached my code
public class User_details
{
[Key]
public Guid user_id { get; set; }
public string First_name { get; set; }
public string Middle_name { get; set; }
public string Last_name { get; set; }
public string Email { get; set; }
public string Password { get; set; }
public DateTime Dob { get; set; }
public string Role { get; set; }
public DateTime Created_on { get; set; }
public Boolean Verification { get; set; }
public string Password_reset_OTP { get; set; }
public byte Profile_pic { get; set; }
}
controller
Contextclass contextclass = new Contextclass();
[System.Web.Http.HttpPost]
public HttpResponseMessage signup([FromBody] User_details userdetails)------>to here im not getting the image
{
try
{
using(Contextclass contextclass=new Contextclass())
{
var mailverification = emailexits(userdetails.Email);
if(mailverification)
{
return Request.CreateResponse(HttpStatusCode.NotFound, "email_already_exits");
}
userdetails.user_id = Guid.NewGuid();
userdetails.Verification = false;
userdetails.Created_on = DateTime.Now.Date;
user_registration user_Registration = new user_registration();
user_Registration.userregistration(userdetails);
senduserverificationmail(userdetails.Email, userdetails.user_id);
var message = Request.CreateResponse(HttpStatusCode.Created);
return message;
}
}
catch(Exception ex)
{
return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex);
}
}
if anybody help it will be really appreciated
Thanks in advance.
Thank you
Preetham hd
Reply
Answers (
3
)
asp.net core filter by two dates
Google pay Mvc application