Search code examples
asp.net-mvchttppostedfile

MVC: when is a file uploaded?


When uploading files to a server and calling a controller method does a HttpPostedFileBase contain the entire file or just information such as name, path, etc?

What I want to know is if the file is uploaded to the server right away or not until calling SaveAs(path) ?


Solution

  • As the file is part of your request, it is uploaded immediatly. It is just buffered into a tempfile which the system will delete once you send the Response.

    If you use SaveAs, you just transfert the file into a permanent location.