Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Get the File Extension from IFromFile MicorsoftAspNetCore

Tags:

c#

asp.net

I'm trying to get the simple file extension for example "XLSX","pdf" and so on instead of the whole raw Content-type when I use IFromFile.ContenType gives me the raw content-type header on the uploaded file, any help is really appreciated

like image 858
SDEV Avatar asked Nov 24 '25 23:11

SDEV


1 Answers

For getting file extension from uploaded file (IFormFile), Use:

System.IO.Path.GetExtension(file.FileName)
like image 62
Md Abdullah Avatar answered Nov 27 '25 15:11

Md Abdullah



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!