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
Guest User
Tech Writer
611
128k
How to store image name in database.
Apr 29 2020 6:59 AM
It's me user detail insert code api.
public
UserResponse AddUserDetail(UserProfileDetails obj_Parameter)
{
UserResponse obj_Response =
new
UserResponse();
UserProfileDetail obj_UserProfileDetail =
new
UserProfileDetail();
try
{
var check_UserDetail = _db.UserProfileDetails.Where(x => x.UserId == obj_Parameter.UserId
/*&& x.CardNumber == obj_Parameter.CardNumber*/
).FirstOrDefault();
if
(check_UserDetail !=
null
)
{
obj_Response.Response = 2;
obj_Response.ErrorMessage =
"User Already exists"
;
}
else
{
obj_UserProfileDetail.FirstName = obj_Parameter.FirstName;
obj_UserProfileDetail.PhoneNumber = obj_Parameter.PhoneNumber;
obj_UserProfileDetail.Address = obj_Parameter.Address;
obj_UserProfileDetail.CityId = obj_Parameter.CityId;
obj_UserProfileDetail.State = obj_Parameter.State;
obj_UserProfileDetail.Pincode = obj_Parameter.Pincode;
obj_UserProfileDetail.Description = obj_Parameter.Description;
obj_UserProfileDetail.CardNumber = obj_Parameter.CardNumber;
obj_UserProfileDetail.CardExpiry = obj_Parameter.CardExpiry;
obj_UserProfileDetail.CVV = obj_Parameter.CVV;
obj_UserProfileDetail.UserImage = obj_Parameter.UserImage;
obj_UserProfileDetail.UserId = obj_Parameter.UserId;
_db.UserProfileDetails.Add(obj_UserProfileDetail);
_db.SaveChanges();
Its me image upload api.
{
UserResponse obj_Response =
new
UserResponse();
// UserProfileDetail obj_UserProfileDetail = new UserProfileDetail();
//UserProfileDetails obj_profile = new UserProfileDetails();
var file = HttpContext.Current.Request.Files.Count > 0 ?
HttpContext.Current.Request.Files[0] :
null
;
if
(!Request.Content.IsMimeMultipartContent())
{
throw
new
HttpResponseException(HttpStatusCode.UnsupportedMediaType);
}
try
{
if
(file !=
null
&& file.ContentLength > 0)
{
var fileName = Path.GetFileName(file.FileName);
var path = Path.Combine(
HttpContext.Current.Server.MapPath(
"~/User_Images/"
),
fileName
);
file.SaveAs(path);
obj_Response.Response = 1;
obj_Response.ErrorMessage =
"Error Not Found"
;
}
else
{
obj_Response.Response = 2;
obj_Response.ErrorMessage =
"Profie was not successfully uploaded"
;
}
}
catch
(System.Exception ex)
{
obj_Response.Response = 0;
obj_Response.ErrorMessage = ex.InnerException.ToString();
}
return
obj_Response;
}
How to save image name in the database . By using multipart form data.Please solve
Reply
Answers (
2
)
tagging issue, In btwn 2 keywords i am trying to give comma
File Upload Problem in MVC