Home > Mobile >  how to get file size of uploaded fiel in web api in .net core
how to get file size of uploaded fiel in web api in .net core

Time:01-14

I want to get the file size of the uploaded file without saving it on the disk. I am getting the file in controller like this

public async Task<IActionResult> GetIncomingFile(IFormFile file){
 // my code here
}

CodePudding user response:

You can use the Length property of the IFormFile object to get the file size. The Length property returns the size of the file in bytes.

Here is an example of how you can use it:

public async Task<IActionResult> GetIncomingFile(IFormFile file){
    long fileSize = file.Length;
    // Do something with the file size
    ...
}
  • Related