π Documentation: Upload.cshtml (AccountingImaging View)
Path:
IrbyImaging/Views/AccountingImaging/Upload.cshtml
π Table of Contents
- Overview & Purpose
- File Structure & Location
- Dependencies & Technologies
- Key Functional Areas
4.1 Razor Directives & ViewBag
4.2 Styles Section
4.3 Upload Form Markup
4.4 Loading Overlay (Spinner)
4.5 JavaScript & Plugins - View Models & Data Models
- API Endpoints & Controller Actions
- Helper Methods & Utilities
- Thirdβparty Integrations
- Sequence Diagram (UML)
- Usage Examples
- Conclusion
1. Overview & Purpose
This Razor View renders a file upload interface for the AccountingImaging module.
Users can browse or dragβandβdrop multiple documents, submit them to the server, and see a loading spinner until the upload completes.
Key goals:
- Intuitive dragβandβdrop or browse upload
- Progress feedback via overlay spinner
- Multi-file support
- Redirect to document preview on success
2. File Structure & Location
| Folder | File |
|---|---|
IrbyImaging/Views/AccountingImaging/ |
Upload.cshtml |
This view is served by the AccountingImagingController (or similar) within the ASP.NET MVC application.
3. Dependencies & Technologies
| Category | Library/Tool |
|---|---|
| Frontβend Framework | HTML5, CSS3, Bootstrap 4+ |
| JavaScript Library | jQuery |
| Upload Plugin | Dropzone.js |
| Spinner Library | spin.js |
| ASP.NET MVC | Razor syntax, Html.BeginForm helper |
4. Key Functional Areas
4.1 Razor Directives & ViewBag
@{
ViewBag.Title = "Form File Upload";
ViewBag.pTitle = "Form File Upload";
ViewBag.pageTitle = "Forms";
var category = ViewBag.category;
}
- ViewBag.Title / pTitle / pageTitle: Sets page headers & SEO
- category: Passed from Controller to filter or group uploads
4.2 Styles Section
@section styles{
<!-- Dropzone CSS -->
<link href="~/assets/libs/dropzone/min/dropzone.min.css" rel="stylesheet" />
}
- Loads Dropzoneβs stylesheet for dragβandβdrop styling.
4.3 Upload Form Markup
@using (Html.BeginForm(
"UploadDocs",
"AccountingImaging",
new { category = category },
FormMethod.Post,
null,
new { enctype = "multipart/form-data" }
)) {
<div class="card">
<div class="card-body">
<h4 class="card-title mb-4">Upload Documents</h4>
<div class="row mb-4">
<i class="display-5 text-muted bx bxs-cloud-upload"></i>
<label class="col-form-label col-lg-3">
Browse or Drop Files to Upload...
</label>
<div class="col-lg-12">
<input
class="form-control"
name="file"
type="file"
multiple
style="height:400%"
/>
</div>
</div>
<div class="row justify-content-end">
<button id="submitbtn" type="submit" class="btn btn-primary">
Upload Documents
</button>
</div>
</div>
</div>
}
- Html.BeginForm: Posts to
UploadDocsaction ofAccountingImagingController enctype="multipart/form-data": Required for file uploads<input type="file" multiple>: Allows selecting or dropping multiple files
4.4 Loading Overlay (Spinner)
<div id="loading">
<div id="loadingcontent">
<p id="loadingspinner">
<br/> Upload in progress. Please wait.....
</p>
</div>
</div>
<style>
#loading {
display: none;
position: fixed; top:0; left:0;
width:100%; height:100%;
background: rgba(255,255,255,0.8);
z-index:1000;
}
/* Center the spinner text */
#loadingspinner {
display: table-cell;
vertical-align: middle;
text-align: center;
font-size: larger;
padding-top:80px;
}
</style>
- Hidden by default (
display:none) - Revealed on submit click to block UI
4.5 JavaScript & Plugins
-
Core Libraries
<script src="~/assets/libs/jquery/jquery.min.js"></script> <script src="~/assets/libs/bootstrap/js/bootstrap.bundle.min.js"></script> -
Dropzone Configuration
<script> function myParamName() { return "file"; } Dropzone.options.dropzoneForm = { paramName: myParamName, autoDiscover: false, autoProcessQueue: false, addRemoveLinks: true, uploadMultiple: true, parallelUploads: 100, init: function() { const dz = this; $("#uploadfile").click(()=> dz.processQueue()); dz.on("queuecomplete", ()=> dz.removeAllFiles()); dz.on("successmultiple", ()=> dz.removeAllFiles()); dz.on("complete", file => { dz.removeAllFiles(); window.location.href = '@Url.Action("DocPreview","Imaging")?fileName=' + file.name; }); }, accept: (file, done) => done() }; </script> -
Loading Spinner (spin.js)
<script src="~/assets/js/spin.js"></script> <script> $(function(){ $("#submitbtn").click(function(){ $("#loading").fadeIn(); const opts = { lines:19, length:28, width:7, scale:0.05, color:'#11467e', animation:'spinner-line-shrink' }; new Spinner(opts).spin(document.getElementById('loading')); }); }); </script>
5. View Models & Data Models
This view uses no stronglyβtyped model. All data is passed via ViewBag or Form Data.
The form postsIFormFile[] file(or equivalent) to the controller action.
6. API Endpoints & Controller Actions
| Action Method | URL | Description |
|---|---|---|
AccountingImaging.UploadDocs |
/AccountingImaging/UploadDocs?category={category} |
Handles multi-file upload via form post. |
Imaging.DocPreview |
/Imaging/DocPreview?fileName={name} |
Displays uploaded document preview. |
7. Helper Methods & Utilities
| Helper | Location | Purpose |
|---|---|---|
myParamName() |
Inline JS | Dynamically sets Dropzone paramName. |
Spinner(opts) |
spin.js | Renders a UI spinner on top of the page. |
8. Thirdβparty Integrations
- Dropzone.js: Elegant dragβandβdrop upload UI
- spin.js: Lightweight animated spinner
- Bootstrap: Responsive layout & components
- jQuery: DOM manipulation & event handling
9. Sequence Diagram (UML)
βββββββββ βββββββββββ ββββββββββββββ ββββββββββββββββ
β User β β Browser β β Web App β β File Storage β
βββββ¬ββββ βββββ¬ββββββ ββββββ¬ββββββββ βββββββ¬βββββββββ
β β β β
β Selects files β β β
ββββββββββββββββΆβ β β
β Show spinner β β
ββββββββββββββββββββΆβ β
β β Save files & meta β
β ββββββββββββββββββββΆβ
β β β
β β Return success β
βββββββββββββββββββββ β
β Hide spinner β β
β Redirect to β β
β DocPreview β β
ββββββββββββββββΆβ β
10. Usage Examples
-
Browse & Upload
- Click Browse or Drop Files
- Select multiple images/PDFs
- Hit Upload Documents
- See loading overlay
- Redirect to preview on finish
-
DragβandβDrop
- Drag files into the input area (if Dropzone config is enabled)
- Click the custom Upload button to process the queue
11. Conclusion
This Upload.cshtml view delivers a rich UI for multiβfile uploads within the AccountingImaging context. Leveraging Dropzone.js for convenience and spin.js for progress feedback, it ensures a seamless user experience. By posting to the UploadDocs action, files are handled serverβside and then previewed via the DocPreview route.
Happy Uploading! π€β¨