简体   繁体   中英

Upload image and video in 2 IFormFile Asp.net Core

I have a form that i need upload images and videos, for images work perfectly, but if i try upload videos all my model return null. If i upload only images work fine. I notice if i remove accept="video/*" from imput for video work, but i need this input for videos

public class AnuncioDTO
{
    public List<IFormFile> FotoUpload { get; set; }
    public List<IFormFile> VideoUpload { get; set; }

}

controller:

     [HttpPost]
    public async Task<IActionResult> SalvarAnuncio(AnuncioDTO model, List<IFormFile> FotoUpload, List<IFormFile> VideoUpload)
    {
    }

my razor

<form asp-action="SalvarAnuncio" asp-controller="Anuncio" method="post" name="criar-anuncio" enctype="multipart/form-data" id="msform">
    
      <input  type="file" asp-for="FotoUpload" name="FotoUpload"  multiple="multiple" class="form-control"  accept="image/*">

      <input type="file" asp-for="VideoUpload" name="VideoUpload" multiple="multiple" class="form-control"  accept="video/*">
 </form>

result if i try upload video, my entire model get null 在此处输入图像描述

if upload only images work fine, but videos is null even i add multiple videos在此处输入图像描述

Solved. The problem was the size of videos, max size suported is 10mb

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM