I'm new to ASP.NET and would be grateful if someone could help. I have my file input in a view:
<input type="file" name="Image" id ="filename" />
<input type="submit" value="Submit" id ="sub" />
Then in the script i send it's value to my Action in a Controller
$(function () {
$.post("Home/NewProject", {Image: $("#filename").val() }, function (data) {});
});
In the Controller's action i get the filename, and rename it as one which will be stored in my project folder ~/App_Data/uploads
[HttpPost]
public ActionResult NewProject(Project model)
{
if (ModelState.IsValid)
{
bool ok = false;
ViewBag.Message = "Publish your project." ;
//var photo = WebImage.GetImageFromRequest();
var fileName = model.Image;
// store the file inside ~/App_Data/uploads folder
var path = Path.Combine(Server.MapPath("~/App_Data/uploads"), fileName);
model.Image = path;
}
}
But how can I actually SAVE this file into folder? Thanks in advance!