© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•2y ago•
74 replies
Gipper

How to go from taking in one photo upload to taking a multiple photo upload

Right now the way I'm doing it is:
public class MyViewModel
{
    // some things
    public IFormFile Photos { get; set; }
    // etc...
}
public class MyViewModel
{
    // some things
    public IFormFile Photos { get; set; }
    // etc...
}

and in the View I pass that ViewModel into I'm taking in the upload like this:
<form asp-action="MyAction" enctype="multipart/form-data">
   Things before
    <div class="custom-file">   
      <p for="customFile">Pick an image:</p>
      <input asp-for="Photos" class="custom-file-input" id="customFile">
   </div> 
   Things after
</form>
<form asp-action="MyAction" enctype="multipart/form-data">
   Things before
    <div class="custom-file">   
      <p for="customFile">Pick an image:</p>
      <input asp-for="Photos" class="custom-file-input" id="customFile">
   </div> 
   Things after
</form>

This only allows uploading one photo at a time. Stack Overflow tells me that the way to do multiple would be:
  <asp:FileUpload ID="fileImages" AllowMultiple="true" runat="server" />
  <asp:FileUpload ID="fileImages" AllowMultiple="true" runat="server" />

But since I didn't even know one can call asp classes in the html tag like that I would really appreciate some help and guidance on how to go from what I currently have to what I want to have.
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements
Next page

Similar Threads

Photo upload always fails
C#CC# / help
10mo ago
how to upload a file in .net project
C#CC# / help
3y ago
Blazor Routing - multiple modules from assemblies in one app.
C#CC# / help
3y ago
Photo or File Uploading
C#CC# / help
3y ago