Overview
TheUploadFilesController provides functionality for uploading files to the server. It uses the HelperPathProvider to manage file paths and storage locations.
Constructor
UploadFilesController
Initializes a new instance of the controller with path management capabilities.Helper service for mapping file paths and URL paths
/workspace/source/MvcCoreUtilidades/Controllers/UploadFilesController.cs:10
Methods
Index
Displays the main upload files view.Returns the Index view
/workspace/source/MvcCoreUtilidades/Controllers/UploadFilesController.cs:15
SubirFile (GET)
Displays the file upload form.Returns the SubirFile view
/workspace/source/MvcCoreUtilidades/Controllers/UploadFilesController.cs:20
SubirFile (POST)
[HttpPost] Handles file upload by saving the file to the server and returning the file path information.The file to upload from the HTTP request
Returns the SubirFile view with ViewData containing:
MENSAJE: Success message with the file pathURLPATH: The URL path where the file can be accessed
- Extracts the filename from the uploaded file
- Maps the physical path using
HelperPathProvider.MapPath()withFolders.Images - Creates a URL path using
HelperPathProvider.MapUrlPath() - Saves the file asynchronously using a
FileStream - Sets ViewData with the file path and URL information
/workspace/source/MvcCoreUtilidades/Controllers/UploadFilesController.cs:25