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
zeeshan akram
1.4k
325
17.9k
How to Save image File in Folder.
Oct 15 2018 3:05 PM
want to save image path in the database, I am using string type image not save in folder but image name also saved in the database. i am using string so SaveAs giving error.
why I am using string? because when I am using public httppostfilebase image file {get;set;} show null value in controller .
imagePath: this variable contains string bytes image file: this variable contain the name of the image
Any expert here to resolve my issue, and tell me what is the problem in my code.
Model
public
string
imagePath {
get
;
set
; }
public
string
imageFile {
get
;
set
; }
C#
byte
[] data = Convert.FromBase64String(Quot[i].imageFile.Replace(
"data:image/jpeg;base64,"
,
""
));
Image img; MemoryStream ms =
new
MemoryStream(data, 0, data.Length);
ms.Write(data, 0, data.Length);
img = Image.FromStream(ms,
true
);
string
fileName = Path.GetFileNameWithoutExtension(Quot[i].imagePath);
string
extension = Path.GetExtension(Quot[i].imagePath);
fileName = fileName + DateTime.Now.ToString(
"dd/MM/yyyy"
) + extension;
Quot[i].imagePath =
"~/AppFiles/Images/"
+ fileName;
fileName = Path.Combine(HttpContext.Current.Server.MapPath(
"~/AppFiles/Images/"
), fileName);
Quot[i].imageFile.SaveAs(fileName);
// Problem in this line due to imageFile string show error SaveAs
Reply
Answers (
2
)
In JQuery CDN purpose
Windows Authentication Login is Disabled