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
Anant Jain
NA
61
8.2k
can't send file from view to controller
Sep 23 2015 6:00 AM
If i add id="addEntry" in beginform then file are not saved in database but when i not write id="addentry" then file is saved in database so, can't understand what i do.
we used id="addentry" for barcode generate jquery .
--------------------------------------------------------------
in view :-
@using (Html.BeginForm("Create", "Euser", FormMethod.Post, new {id = "addEntry", enctype = "multipart/form-data"}))
--------------------------------------------------------------
in Controller:-
public ActionResult Create(Table table, FormCollection fc, HttpPostedFileBase file)
-----------------------------------------------------------------
Save Code:-
if (file != null && file.ContentLength > 0)
{
try
{
path = Path.Combine(Server.MapPath("~/Upload"),
Path.GetFileName(file.FileName));
file.SaveAs(path);
tapalmaster.FileUploadPath = Path.GetFileName(file.FileName);
ViewBag.Message = "File uploaded successfully";
byte[] pic = new byte[file.ContentLength];
file.InputStream.Read(pic, 0, file.ContentLength);
}
catch (Exception ex)
{
ViewBag.Message = "ERROR:" + ex.Message.ToString();
}
}
else
{
ViewBag.Message = "You have not specified a file.";
}
Pz Give me a best solution
Reply
Answers (
1
)
How to Intigrate with twitter
How to hide querystring information in the url