Click here to Skip to main content
15,884,425 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have uploaded file by using this controller
SQL


C#
[HttpPost]
public ActionResult Create(AdulLiteracyTeachers adulliteracyteachers, HttpPostedFileBase[] files)
{
foreach (HttpPostedFileBase file in files)
{
string path = System.IO.Path.Combine(Server.MapPath("~/App_Data"), System.IO.Path.GetFileName(file.FileName));
file.SaveAs(path);
}
if (ModelState.IsValid)
{
db.AdulLiteracyTeachers.Add(adulliteracyteachers);
db.SaveChanges();
return RedirectToAction("Index");
}



C#


the view is :
C#
using (Html.BeginForm("Create", "AdultLiteracyTeachers", FormMethod.Post, new { enctype = "multipart/form-data" }))
{ 
@Html.ValidationSummary(true)

<label for="file">Upload Image:</label>
<input type="file" name="files" value="" multiple="multiple"/>

<input name="Upload" type="submit" value="Create" />


I want to save the file name in database when i open the specifc record how the picture is generated with name ?
Actually I ahve more values student name , Rollno[key] and iam not using any image propety in model . How to use this and when I wnat to see the data how Can i Rtirive by path the specific image
Posted
Comments
DotNet WeblineIndia 19-Apr-14 4:48am    
do you have any field in model for saving the path of image in "AdulLiteracyTeachers"? and Do you want to save multiple images?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900