Search code examples
c#.netasp.netfile

$_FILES['file']['tmp_name'] equivalents in C#


what is equivalents to $_FILES['file']['tmp_name'] of PHP in C#.net?


Solution

  • The equivalent in ASP.NET is:

    Request.Files["file"].SaveAs("Your filename");
    

    ASP.NET do not expose the temporary filename which is used during the file upload.

    If you want to validate the contents of the file you could read from Request.Files["file"].InputStream.

    More information at MSDN: https://learn.microsoft.com/en-us/dotnet/api/system.web.httprequest.files