Is there an easy way to show a blocking Bootstrap progress bar while a file is loading?
The progress is shown in the status bar in chrome as the file is uploaded:
I'd like the dialog to look something like this
My Action looks something like this:
[HttpPost]
public ActionResult Upload(UploadViewModel model)
{
using (MemoryStream uploadedFile = new MemoryStream())
{
model.File.InputStream.CopyTo(uploadedFile);
uploadService.UploadFile(uploadedFile, model.File.ContentType)
return View();
}
}
Model:
public class UploadViewModel
{
[Required]
public HttpPostedFileBase File { get; set; }
}
View:
@model Bleh.Web.Models.UploadViewModel
@using (Html.BeginForm("Upload", "Home",
FormMethod.Post, new { enctype = "multipart/form-data", @role = "form" }))
{
<div class="form-group">
@Html.LabelFor(m => m.File)
@Html.TextBoxFor(m => m.File, new { type = "file", @class = "form-control" })
<strong>@Html.ValidationMessageFor(m => m.File, null, new { @class = "label label-danger" })</strong>
</div>
<div class="form-group noleftpadding">
<input type="submit" value="Upload File" class="btn btn-primary" />
</div>
}
Is there an easy way to process the percentage that the browser displays and apply it to the progress bar?
See Question&Answers more detail:os