I am developing a website in MVC 4, where user fill some information and save it to upload. all the information except image is being saved on server using Javascript, Json
if (file != null && file.ContentLength > 0)
{
string filename = Path.GetFileName(file.FileName);
string imgpath = Path.Combine(Server.MapPath("~/Img/"), filename);
file.SaveAs(imgpath);
student.photo = imgpath;
}
function readURL(input)
{
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
$('#imgUser')
.attr('src', e.target.result)
.width(150)
.height(200);
};
reader.readAsDataURL(input.files[0]);
}
}