title: Image upload stuck with blazor server and BlazorInputFile
body: <p>I have a problem while uploading images to an app with blazor server.</p>
  <p>I am currently using <code>BlazorInputFile</code> because I am using <strong>.Net Core 3.1</strong></p>
  <p>When I try to upload a series of images (100 images of about 500 kb size) after a while the upload is interrupted and the image gets corrupted. When the image in the upload destination folder is interrupted, it is always like this:</p>
  <p><a href="https://i.stack.imgur.com/JQN5J.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JQN5J.png" alt="When the image in the upload destination folder is interrupted, it is always like this" /></a></p>
  <p>So this is my code for upload images:</p>
  <pre><code>&lt;InputFile id=&quot;fileInput112&quot; OnChange=&quot;SelectFiles&quot; hidden multiple accept=&quot;.jpg, .jpeg, .png&quot; /&gt;
  
  @code{
  
      private async void SelectFiles(IFileListEntry[] files)
      {
          var folderProductImage = &quot;images/products/&quot;;
          
          foreach (var item in files)
          {
              await Task.Run(() =&gt; UploadProductImage(item, folderProductImage));
          }
      }
      
      private async Task UploadProductImage(IFileListEntry item, string destDirName)
      {
          string fileUploadPath = Path.Combine(destDirName, item.Name);
          
          using (FileStream writer = new FileStream(fileUploadPath, FileMode.Create, FileAccess.ReadWrite))
          {
              await item.Data.CopyToAsync(writer);
          }
      }
  }
  </code></pre>