An asp.net mvc action takes an HttpPostedFileBase parameter:
public ActionResult Save(HttpPostedFileBase file)
{
//Q1: at the start of this action method, what's the status of this file?
//UploadCompleted or Uploading or something else?
//Q2: where is the file stored? memory or a temp file?
if (answer of Q1 is Uploading)
{
//Q3a: what happens if file.SaveAs is invoked?
//block the current thread until the file is uploaded?
}
else if (answer if Q1 is UploadCompleted)
{
//Q3b: which means the developer can do nothing before the file is uploaded?
//if the business logic limits the size of the file(e.g. <= 5MB), how can we
//prevent evil-intended uploading?
}
}
Q4 here: I want to record the total time of this request, when the user begins to upload the file, the timer starts.when the user finished uploading the file(or my Save action is completed), the timer ends. How can I know when the user begins to upload?