Asp.net core uploading file and storing file url to databaseHow can I get my webapp's base URL in ASP.NET MVC?Getting full URL of action in ASP.NET MVCFile Upload ASP.NET MVC 3.0How to unit test Asp.net MVC fileUploadUnit test controller - membership errorHow do you create a custom AuthorizeAttribute in ASP.NET Core?Read file from model asp.net core 1.1Populate dropdownlist from database in asp.net MVC in a formmodelstate.isvalid false because the item always nullASP.net MVC problem in Controller managing a [HttpPost] : renders Layout and Page twice

Why did IBM make the PC BIOS source code public?

Solving pricing problem heuristically in column generation algorithm for VRP

When was "Fredo" an insult to Italian-Americans?

Setting up a Mathematical Institute of Refereeing?

If a person claims to know anything could it be disproven by saying 'prove that we are not in a simulation'?

Sums of binomial coefficients weighted by incomplete gamma

Solving a maximum minimum problem

What modifiers are added to the attack and damage rolls of this unique longbow from Waterdeep: Dragon Heist?

What's the relationship betweeen MS-DOS and XENIX?

Heyawake: An Introductory Puzzle

What's the point of writing that I know will never be used or read?

How to programatically get all linked items for a given Sitecore item?

Unconventional examples of mathematical modelling

What can I do to increase the amount of LEDs I can power with a pro micro?

Would the USA be eligible to join the European Union?

Scam? Phone call from "Department of Social Security" asking me to call back

How do figure out how powerful I am, when my abilities far exceed my knowledge?

Perpendicular symbol with litle square

Bringing Power Supplies on Plane?

Airline power sockets shut down when I plug my computer in. How can I avoid that?

How can I shoot a bow using Strength instead of Dexterity?

Why aren't rockets built with truss structures inside their fuel & oxidizer tanks to increase structural strength?

Why aren’t there water shutoff valves for each room?

Did Michelle Obama have a staff of 23; and Melania have a staff of 4?



Asp.net core uploading file and storing file url to database


How can I get my webapp's base URL in ASP.NET MVC?Getting full URL of action in ASP.NET MVCFile Upload ASP.NET MVC 3.0How to unit test Asp.net MVC fileUploadUnit test controller - membership errorHow do you create a custom AuthorizeAttribute in ASP.NET Core?Read file from model asp.net core 1.1Populate dropdownlist from database in asp.net MVC in a formmodelstate.isvalid false because the item always nullASP.net MVC problem in Controller managing a [HttpPost] : renders Layout and Page twice






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1















I have the code working in a new seperate test project how ever it will not work with my excisting work project. I am trying to upload a file as part of a form, store it in a folder in wwwroot and store the url in a database. I have posted the code below.The program compiles and runs but does not store anything when create button is pressed. any help would be greatly appreciated.



//Model



namespace PostProjectEvaluations.Web.Models
{
public partial class Projects

[Key]
public int ProjectId get; set;
[Required]
[StringLength(300)]
public string Name get; set;
[Required]
[StringLength(50)]
public string Manager get; set;

public string FilePath get; set;


public class ProjectsVM

public string Name get; set;
public IFormFile File get; set;



//Controller



namespace PostProjectEvaluations.Web.Controllers

public class projectsController : Controller

private readonly IApplicationRepository ApplicationRepository;
private readonly PostProjectEvaluationsContext _context;
private IHostingEnvironment mxHostingEnvironment get; set;
private object objproject;

public projectsController(IApplicationRepository applicationRepository,
IHostingEnvironment hostingEnvironment, PostProjectEvaluationsContext context)

mxHostingEnvironment = hostingEnvironment;
ApplicationRepository = applicationRepository;
_context = context;



public IActionResult Index()

ViewBag.dataSource = ApplicationRepository.GetAllProjects().ToList();
var projects = ApplicationRepository.GetAllProjects();
return View(projects);


[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Index(ProjectsVM projectsVM)

if (projectsVM.File != null)

//upload files to wwwroot
var fileName = Path.GetFileName(projectsVM.File.FileName);
var filePath = Path.Combine(mxHostingEnvironment.WebRootPath, "Uploads", fileName);


using (var fileSteam = new FileStream(filePath, FileMode.Create))

await projectsVM.File.CopyToAsync(fileSteam);

//your logic to save filePath to database, for example

Projects projects = new Projects();
projects.Name = projectsVM.Name;
projects.FilePath = filePath;

_context.Projects.Add(projects);
_context.SaveChanges();

else



return View("Index");

public IActionResult Details(int id)

var project = ApplicationRepository.GetProjects(id);
return View(project);


[HttpGet]
public IActionResult Create()


var project = new Projects();
return View(project);


[HttpPost]
public IActionResult Create(Projects projects)

ApplicationRepository.Create(projects);
return RedirectToAction("Index");





public IActionResult Delete(int id)

var project = ApplicationRepository.GetProjects(id);
ApplicationRepository.Delete(project);
return RedirectToAction("Index");



[HttpGet]
public IActionResult Edit(int id)

var project = ApplicationRepository.GetProjects(id);
//mxApplicationRepository.SaveChangesAsync();
return View(project);

[HttpPost]
public IActionResult Edit(Projects projects)

ApplicationRepository.Edit(projects);
//mxApplicationRepository.SaveChangesAsync();
return RedirectToAction("Index");








//View



 <form enctype="multipart/form-data" asp-controller="Projects" asp-action="Create" method="post" class="form-horizontal">
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<div class="form-body">
<h3 class="form-section">Project Info</h3>
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label class="control-label col-md-3">Project Name</label>
<div class="col-md-9">
<input asp-for="Name" class="form-control" placeholder="Name">
<span asp-validation-for="Name" class="text-danger"></span>
</div>
</div>
</div>
<!--/span-->
<div class="col-md-6">
<div class="form-group">
<label class="control-label col-md-3">Project Manager</label>
<div class="col-md-9">
<input asp-for="Manager" class="form-control" placeholder="Name">
</div>
</div>
</div>
<!--/span-->
</div>

<!--/span-->
</div>
<h3 class="form-section">Project Files</h3>
<!--/row-->
<div class="row">
<div>
<div class="col-md-6">
<div class="col-md-10">
<p>Upload one or more files using this form:</p>
<input type="file" name="files" multiple />
</div>
</div>
</div>
<div>
</div>
</div>

<div class="form-actions right">
<input type="submit" class="btn blue-assembly" name="submitButton" value="Save" />
<a asp-action="Index" class="btn default" onclick="cancelClick()">Cancel</a>
</div>











share|improve this question
























  • Can you check if projectsVM has a value? i don't think that the model binder is able to bind your input field to this variable because the name on the input field is "files". You could try something like List<IFormFile> files as your parameter in the save function

    – Elias Johannes
    Mar 27 at 12:25











  • Double check that your file is not null, and I think you'll have to replace WebRootPath with ContentRootPath. also check your Debug folder from where your application is ran maybe it's saving the file there.

    – Anton Toshik
    Mar 27 at 12:35











  • In debug output i get this error, Cannot insert the value NULL into column 'FilePath', table 'PostProjectEvaluations.dbo.Projects'; column does not allow nulls. INSERT fails.

    – Karl Mcgeough
    Mar 27 at 13:43


















1















I have the code working in a new seperate test project how ever it will not work with my excisting work project. I am trying to upload a file as part of a form, store it in a folder in wwwroot and store the url in a database. I have posted the code below.The program compiles and runs but does not store anything when create button is pressed. any help would be greatly appreciated.



//Model



namespace PostProjectEvaluations.Web.Models
{
public partial class Projects

[Key]
public int ProjectId get; set;
[Required]
[StringLength(300)]
public string Name get; set;
[Required]
[StringLength(50)]
public string Manager get; set;

public string FilePath get; set;


public class ProjectsVM

public string Name get; set;
public IFormFile File get; set;



//Controller



namespace PostProjectEvaluations.Web.Controllers

public class projectsController : Controller

private readonly IApplicationRepository ApplicationRepository;
private readonly PostProjectEvaluationsContext _context;
private IHostingEnvironment mxHostingEnvironment get; set;
private object objproject;

public projectsController(IApplicationRepository applicationRepository,
IHostingEnvironment hostingEnvironment, PostProjectEvaluationsContext context)

mxHostingEnvironment = hostingEnvironment;
ApplicationRepository = applicationRepository;
_context = context;



public IActionResult Index()

ViewBag.dataSource = ApplicationRepository.GetAllProjects().ToList();
var projects = ApplicationRepository.GetAllProjects();
return View(projects);


[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Index(ProjectsVM projectsVM)

if (projectsVM.File != null)

//upload files to wwwroot
var fileName = Path.GetFileName(projectsVM.File.FileName);
var filePath = Path.Combine(mxHostingEnvironment.WebRootPath, "Uploads", fileName);


using (var fileSteam = new FileStream(filePath, FileMode.Create))

await projectsVM.File.CopyToAsync(fileSteam);

//your logic to save filePath to database, for example

Projects projects = new Projects();
projects.Name = projectsVM.Name;
projects.FilePath = filePath;

_context.Projects.Add(projects);
_context.SaveChanges();

else



return View("Index");

public IActionResult Details(int id)

var project = ApplicationRepository.GetProjects(id);
return View(project);


[HttpGet]
public IActionResult Create()


var project = new Projects();
return View(project);


[HttpPost]
public IActionResult Create(Projects projects)

ApplicationRepository.Create(projects);
return RedirectToAction("Index");





public IActionResult Delete(int id)

var project = ApplicationRepository.GetProjects(id);
ApplicationRepository.Delete(project);
return RedirectToAction("Index");



[HttpGet]
public IActionResult Edit(int id)

var project = ApplicationRepository.GetProjects(id);
//mxApplicationRepository.SaveChangesAsync();
return View(project);

[HttpPost]
public IActionResult Edit(Projects projects)

ApplicationRepository.Edit(projects);
//mxApplicationRepository.SaveChangesAsync();
return RedirectToAction("Index");








//View



 <form enctype="multipart/form-data" asp-controller="Projects" asp-action="Create" method="post" class="form-horizontal">
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<div class="form-body">
<h3 class="form-section">Project Info</h3>
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label class="control-label col-md-3">Project Name</label>
<div class="col-md-9">
<input asp-for="Name" class="form-control" placeholder="Name">
<span asp-validation-for="Name" class="text-danger"></span>
</div>
</div>
</div>
<!--/span-->
<div class="col-md-6">
<div class="form-group">
<label class="control-label col-md-3">Project Manager</label>
<div class="col-md-9">
<input asp-for="Manager" class="form-control" placeholder="Name">
</div>
</div>
</div>
<!--/span-->
</div>

<!--/span-->
</div>
<h3 class="form-section">Project Files</h3>
<!--/row-->
<div class="row">
<div>
<div class="col-md-6">
<div class="col-md-10">
<p>Upload one or more files using this form:</p>
<input type="file" name="files" multiple />
</div>
</div>
</div>
<div>
</div>
</div>

<div class="form-actions right">
<input type="submit" class="btn blue-assembly" name="submitButton" value="Save" />
<a asp-action="Index" class="btn default" onclick="cancelClick()">Cancel</a>
</div>











share|improve this question
























  • Can you check if projectsVM has a value? i don't think that the model binder is able to bind your input field to this variable because the name on the input field is "files". You could try something like List<IFormFile> files as your parameter in the save function

    – Elias Johannes
    Mar 27 at 12:25











  • Double check that your file is not null, and I think you'll have to replace WebRootPath with ContentRootPath. also check your Debug folder from where your application is ran maybe it's saving the file there.

    – Anton Toshik
    Mar 27 at 12:35











  • In debug output i get this error, Cannot insert the value NULL into column 'FilePath', table 'PostProjectEvaluations.dbo.Projects'; column does not allow nulls. INSERT fails.

    – Karl Mcgeough
    Mar 27 at 13:43














1












1








1








I have the code working in a new seperate test project how ever it will not work with my excisting work project. I am trying to upload a file as part of a form, store it in a folder in wwwroot and store the url in a database. I have posted the code below.The program compiles and runs but does not store anything when create button is pressed. any help would be greatly appreciated.



//Model



namespace PostProjectEvaluations.Web.Models
{
public partial class Projects

[Key]
public int ProjectId get; set;
[Required]
[StringLength(300)]
public string Name get; set;
[Required]
[StringLength(50)]
public string Manager get; set;

public string FilePath get; set;


public class ProjectsVM

public string Name get; set;
public IFormFile File get; set;



//Controller



namespace PostProjectEvaluations.Web.Controllers

public class projectsController : Controller

private readonly IApplicationRepository ApplicationRepository;
private readonly PostProjectEvaluationsContext _context;
private IHostingEnvironment mxHostingEnvironment get; set;
private object objproject;

public projectsController(IApplicationRepository applicationRepository,
IHostingEnvironment hostingEnvironment, PostProjectEvaluationsContext context)

mxHostingEnvironment = hostingEnvironment;
ApplicationRepository = applicationRepository;
_context = context;



public IActionResult Index()

ViewBag.dataSource = ApplicationRepository.GetAllProjects().ToList();
var projects = ApplicationRepository.GetAllProjects();
return View(projects);


[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Index(ProjectsVM projectsVM)

if (projectsVM.File != null)

//upload files to wwwroot
var fileName = Path.GetFileName(projectsVM.File.FileName);
var filePath = Path.Combine(mxHostingEnvironment.WebRootPath, "Uploads", fileName);


using (var fileSteam = new FileStream(filePath, FileMode.Create))

await projectsVM.File.CopyToAsync(fileSteam);

//your logic to save filePath to database, for example

Projects projects = new Projects();
projects.Name = projectsVM.Name;
projects.FilePath = filePath;

_context.Projects.Add(projects);
_context.SaveChanges();

else



return View("Index");

public IActionResult Details(int id)

var project = ApplicationRepository.GetProjects(id);
return View(project);


[HttpGet]
public IActionResult Create()


var project = new Projects();
return View(project);


[HttpPost]
public IActionResult Create(Projects projects)

ApplicationRepository.Create(projects);
return RedirectToAction("Index");





public IActionResult Delete(int id)

var project = ApplicationRepository.GetProjects(id);
ApplicationRepository.Delete(project);
return RedirectToAction("Index");



[HttpGet]
public IActionResult Edit(int id)

var project = ApplicationRepository.GetProjects(id);
//mxApplicationRepository.SaveChangesAsync();
return View(project);

[HttpPost]
public IActionResult Edit(Projects projects)

ApplicationRepository.Edit(projects);
//mxApplicationRepository.SaveChangesAsync();
return RedirectToAction("Index");








//View



 <form enctype="multipart/form-data" asp-controller="Projects" asp-action="Create" method="post" class="form-horizontal">
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<div class="form-body">
<h3 class="form-section">Project Info</h3>
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label class="control-label col-md-3">Project Name</label>
<div class="col-md-9">
<input asp-for="Name" class="form-control" placeholder="Name">
<span asp-validation-for="Name" class="text-danger"></span>
</div>
</div>
</div>
<!--/span-->
<div class="col-md-6">
<div class="form-group">
<label class="control-label col-md-3">Project Manager</label>
<div class="col-md-9">
<input asp-for="Manager" class="form-control" placeholder="Name">
</div>
</div>
</div>
<!--/span-->
</div>

<!--/span-->
</div>
<h3 class="form-section">Project Files</h3>
<!--/row-->
<div class="row">
<div>
<div class="col-md-6">
<div class="col-md-10">
<p>Upload one or more files using this form:</p>
<input type="file" name="files" multiple />
</div>
</div>
</div>
<div>
</div>
</div>

<div class="form-actions right">
<input type="submit" class="btn blue-assembly" name="submitButton" value="Save" />
<a asp-action="Index" class="btn default" onclick="cancelClick()">Cancel</a>
</div>











share|improve this question














I have the code working in a new seperate test project how ever it will not work with my excisting work project. I am trying to upload a file as part of a form, store it in a folder in wwwroot and store the url in a database. I have posted the code below.The program compiles and runs but does not store anything when create button is pressed. any help would be greatly appreciated.



//Model



namespace PostProjectEvaluations.Web.Models
{
public partial class Projects

[Key]
public int ProjectId get; set;
[Required]
[StringLength(300)]
public string Name get; set;
[Required]
[StringLength(50)]
public string Manager get; set;

public string FilePath get; set;


public class ProjectsVM

public string Name get; set;
public IFormFile File get; set;



//Controller



namespace PostProjectEvaluations.Web.Controllers

public class projectsController : Controller

private readonly IApplicationRepository ApplicationRepository;
private readonly PostProjectEvaluationsContext _context;
private IHostingEnvironment mxHostingEnvironment get; set;
private object objproject;

public projectsController(IApplicationRepository applicationRepository,
IHostingEnvironment hostingEnvironment, PostProjectEvaluationsContext context)

mxHostingEnvironment = hostingEnvironment;
ApplicationRepository = applicationRepository;
_context = context;



public IActionResult Index()

ViewBag.dataSource = ApplicationRepository.GetAllProjects().ToList();
var projects = ApplicationRepository.GetAllProjects();
return View(projects);


[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Index(ProjectsVM projectsVM)

if (projectsVM.File != null)

//upload files to wwwroot
var fileName = Path.GetFileName(projectsVM.File.FileName);
var filePath = Path.Combine(mxHostingEnvironment.WebRootPath, "Uploads", fileName);


using (var fileSteam = new FileStream(filePath, FileMode.Create))

await projectsVM.File.CopyToAsync(fileSteam);

//your logic to save filePath to database, for example

Projects projects = new Projects();
projects.Name = projectsVM.Name;
projects.FilePath = filePath;

_context.Projects.Add(projects);
_context.SaveChanges();

else



return View("Index");

public IActionResult Details(int id)

var project = ApplicationRepository.GetProjects(id);
return View(project);


[HttpGet]
public IActionResult Create()


var project = new Projects();
return View(project);


[HttpPost]
public IActionResult Create(Projects projects)

ApplicationRepository.Create(projects);
return RedirectToAction("Index");





public IActionResult Delete(int id)

var project = ApplicationRepository.GetProjects(id);
ApplicationRepository.Delete(project);
return RedirectToAction("Index");



[HttpGet]
public IActionResult Edit(int id)

var project = ApplicationRepository.GetProjects(id);
//mxApplicationRepository.SaveChangesAsync();
return View(project);

[HttpPost]
public IActionResult Edit(Projects projects)

ApplicationRepository.Edit(projects);
//mxApplicationRepository.SaveChangesAsync();
return RedirectToAction("Index");








//View



 <form enctype="multipart/form-data" asp-controller="Projects" asp-action="Create" method="post" class="form-horizontal">
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<div class="form-body">
<h3 class="form-section">Project Info</h3>
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label class="control-label col-md-3">Project Name</label>
<div class="col-md-9">
<input asp-for="Name" class="form-control" placeholder="Name">
<span asp-validation-for="Name" class="text-danger"></span>
</div>
</div>
</div>
<!--/span-->
<div class="col-md-6">
<div class="form-group">
<label class="control-label col-md-3">Project Manager</label>
<div class="col-md-9">
<input asp-for="Manager" class="form-control" placeholder="Name">
</div>
</div>
</div>
<!--/span-->
</div>

<!--/span-->
</div>
<h3 class="form-section">Project Files</h3>
<!--/row-->
<div class="row">
<div>
<div class="col-md-6">
<div class="col-md-10">
<p>Upload one or more files using this form:</p>
<input type="file" name="files" multiple />
</div>
</div>
</div>
<div>
</div>
</div>

<div class="form-actions right">
<input type="submit" class="btn blue-assembly" name="submitButton" value="Save" />
<a asp-action="Index" class="btn default" onclick="cancelClick()">Cancel</a>
</div>








asp.net asp.net-mvc asp.net-core






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 27 at 11:53









Karl McgeoughKarl Mcgeough

112 bronze badges




112 bronze badges















  • Can you check if projectsVM has a value? i don't think that the model binder is able to bind your input field to this variable because the name on the input field is "files". You could try something like List<IFormFile> files as your parameter in the save function

    – Elias Johannes
    Mar 27 at 12:25











  • Double check that your file is not null, and I think you'll have to replace WebRootPath with ContentRootPath. also check your Debug folder from where your application is ran maybe it's saving the file there.

    – Anton Toshik
    Mar 27 at 12:35











  • In debug output i get this error, Cannot insert the value NULL into column 'FilePath', table 'PostProjectEvaluations.dbo.Projects'; column does not allow nulls. INSERT fails.

    – Karl Mcgeough
    Mar 27 at 13:43


















  • Can you check if projectsVM has a value? i don't think that the model binder is able to bind your input field to this variable because the name on the input field is "files". You could try something like List<IFormFile> files as your parameter in the save function

    – Elias Johannes
    Mar 27 at 12:25











  • Double check that your file is not null, and I think you'll have to replace WebRootPath with ContentRootPath. also check your Debug folder from where your application is ran maybe it's saving the file there.

    – Anton Toshik
    Mar 27 at 12:35











  • In debug output i get this error, Cannot insert the value NULL into column 'FilePath', table 'PostProjectEvaluations.dbo.Projects'; column does not allow nulls. INSERT fails.

    – Karl Mcgeough
    Mar 27 at 13:43

















Can you check if projectsVM has a value? i don't think that the model binder is able to bind your input field to this variable because the name on the input field is "files". You could try something like List<IFormFile> files as your parameter in the save function

– Elias Johannes
Mar 27 at 12:25





Can you check if projectsVM has a value? i don't think that the model binder is able to bind your input field to this variable because the name on the input field is "files". You could try something like List<IFormFile> files as your parameter in the save function

– Elias Johannes
Mar 27 at 12:25













Double check that your file is not null, and I think you'll have to replace WebRootPath with ContentRootPath. also check your Debug folder from where your application is ran maybe it's saving the file there.

– Anton Toshik
Mar 27 at 12:35





Double check that your file is not null, and I think you'll have to replace WebRootPath with ContentRootPath. also check your Debug folder from where your application is ran maybe it's saving the file there.

– Anton Toshik
Mar 27 at 12:35













In debug output i get this error, Cannot insert the value NULL into column 'FilePath', table 'PostProjectEvaluations.dbo.Projects'; column does not allow nulls. INSERT fails.

– Karl Mcgeough
Mar 27 at 13:43






In debug output i get this error, Cannot insert the value NULL into column 'FilePath', table 'PostProjectEvaluations.dbo.Projects'; column does not allow nulls. INSERT fails.

– Karl Mcgeough
Mar 27 at 13:43













1 Answer
1






active

oldest

votes


















1














Include your model in view as in the first line



@ProjectsVM


You have to give the same name as a model
Try this:



 <input type="file" id= name="File" multiple />





share|improve this answer
























    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55376571%2fasp-net-core-uploading-file-and-storing-file-url-to-database%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    Include your model in view as in the first line



    @ProjectsVM


    You have to give the same name as a model
    Try this:



     <input type="file" id= name="File" multiple />





    share|improve this answer





























      1














      Include your model in view as in the first line



      @ProjectsVM


      You have to give the same name as a model
      Try this:



       <input type="file" id= name="File" multiple />





      share|improve this answer



























        1












        1








        1







        Include your model in view as in the first line



        @ProjectsVM


        You have to give the same name as a model
        Try this:



         <input type="file" id= name="File" multiple />





        share|improve this answer













        Include your model in view as in the first line



        @ProjectsVM


        You have to give the same name as a model
        Try this:



         <input type="file" id= name="File" multiple />






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 27 at 14:28









        Kinjal ParmarKinjal Parmar

        2051 silver badge12 bronze badges




        2051 silver badge12 bronze badges





















            Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







            Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.



















            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55376571%2fasp-net-core-uploading-file-and-storing-file-url-to-database%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

            Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

            Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript