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
nizam nizam
NA
0
12.3k
MVC 4 How to upload image file and show
Feb 20 2015 7:19 AM
namespace StudentApp.Models
{
[MetadataType(typeof (Sdetails))]
public partial class tbl_Sdetails
{
[Display(Name = "Photo")]
[FileTypes("jpeg,png,jpg",ErrorMessage = "Invalid format")]
public HttpPostedFileWrapper PostedPhoto { get; set; }
public string PhotoPath { get; set; }
}
<h2>SdetailsAdd</h2>
@using (Html.BeginForm("SdetailsAdd","Sdetails", FormMethod.Post,new {enctype="multipart/form-data"}))
{
<td>@Html.LabelFor(a => a.Image)</td>
@Html.TextBoxFor(m=>m.PostedPhoto,string.Empty,new {@type="file"})
public ActionResult SdList(string txtSearch)
{
var sd = db.tbl_Sdetails.ToList();
if (!string.IsNullOrEmpty(txtSearch))
{
sd = sd.Where(s => s.studentName.ToUpper().Contains(txtSearch.ToUpper())).ToList();
}
foreach (var student in sd)
{
if (student.Image != null)
{
string.Format("data; image/gif;based64,{0}", Convert.ToBase64String(student.Image));
}
}
return View(sd);
}
Reply
Answers (
4
)
Problem with Autocomplete textbox event
Could not load file or assembly 'System.Web.Mvc, Version=5.1