BlazorInputFileExtended 2.4.22
dotnet add package BlazorInputFileExtended --version 2.4.22
NuGet\Install-Package BlazorInputFileExtended -Version 2.4.22
<PackageReference Include="BlazorInputFileExtended" Version="2.4.22" />
paket add BlazorInputFileExtended --version 2.4.22
#r "nuget: BlazorInputFileExtended, 2.4.22"
// Install BlazorInputFileExtended as a Cake Addin #addin nuget:?package=BlazorInputFileExtended&version=2.4.22 // Install BlazorInputFileExtended as a Cake Tool #tool nuget:?package=BlazorInputFileExtended&version=2.4.22
Description
Extend the traditional component InputFile with more options like drag and drop, copy and paste (if drag and drop is enabled) and upload methods directly. Less coding for all. Oficial web documentation and examples.
How to use
Import the name space adding to _Imports.razor this line:
@using BlazorInputFileExtended
Add into your component:
<InputFileExtended TargetToPostFile="[full url endpoint where to post the file/files]" ButtonShow="true" CleanOnSuccessUpload="true" />
- Where TargetToPostFile is the endpoint where will upload the file.
- ButtonShow display the upload button
- CleanOnSuccessUpload remove the file form the view after upload the file.
Properties
Upload management
- MultiFile: Indicates can accept multiple files on the selection box.
- MaxUploatedFiles: Indicates how many files can be selected. Default 5.
- MaxFileSize: Indicates maximum file size per each file selected. Default 512000 bytes.
- CleanOnSuccessUpload: Indicates clean all loaded files after upload to the server. Default false.
- SelectionText: Set the text when files are chosen. Default chosen.
- SelectionCss: Set the CSS to format the text when files are chosen. Default info.
Input formating
- InputContent: HTML for the choose file input.
- InputCss: Set the CSS to format the input file tag.
- InputTitle: Set the title when the user hover the input file tag.
- InputFileTypes: Indicates what kind of files can be selected. Ex: images/*.
Button formating
- ButtonContent: HTML inside the button for upload.
- ButtonShow: Button to upload can be hide if you want to manage externally. Default true.
- ButtonCss: Set the CSS to format the button.
- ButtonTitle: Set the title when the user hover the button.
Preview setup only for images
- IsImage: Indicate the files to select is images. Default true.
- ShowPreview: Indicates if need to show a preview for the file selected. Default true.
- PreviewWrapperCss: Set the CSS to format the wrapper for the figure tag content the image. Default image
- FileCss: Set the CSS to format the image tag.
- FileBytes: Store the byte[] about the last image selected.
Methods
- FormSave: Required component reference, and can use with EditForm event OnValidSubmit. This action send the form.
-
- If TargetDataObject is set, this have preference when send the form.
-
- If TargetDataObject is not set, then send the Context with the form data.
Drag and Drop
- CanDropFiles: Enable drag and drop.
- DropZoneCss: CSS to use for format the drop zone.
- DroppingCss: CSS to use when user are dropping the file.
Methods Drag and Drop
- LoadDropScriptsAsync: If the component load with CanDropfiles = false, with this method can change and enable dropping files.
- UnLoadDropScriptsAsync: If the component is already setup for dropping files with this method can disabled.
Post actions
If you want to upload files with some other data, send the model data.
- TargetFormDataContent: MultipartFormDataContent with the form data to send with the files.
- TargetDataObject: Object with the data model to send with the files. This will encapsulated into a MultipartFormDataContent before send to server.
- TargetFormFieldName: Indicates the field form name to send the files. Default files
- TargetToPostFile: Indicate the URL to use for the post action. If it's not setup return a event error if try to upload images.
- AutoUpload: Indicate to upload the file when is selected. Required TargetToPostFile with the url to upload the file.
Events
- OnUploadedFile: When each file is uploaded. Returns FileUploadEventArgs.
- OnUploadComleted: When all files is uploaded. Returns FilesUploadEventArgs.
- OnError: When some exception. Returns InputFileException.
- OnSave: When click on SAVE button. Returns HttpMessageResponse.
- OnChange: Normal InputFile OnChange. Returns InputFileChangeEventArgs.
Exception
- InputFileException: encapsulate the exceptions when upload file.
Handler
You can use the class BlazorInputFileExtenden.InputFileHandler to implement your own logic or the logic for the Authorization send files.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net6.0
- Microsoft.AspNetCore.Components.Web (>= 6.0.20)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated | |
---|---|---|---|
2.4.22 | 1,905 | 8/6/2023 | |
2.4.21 | 163 | 8/6/2023 | |
2.4.20 | 171 | 7/30/2023 | |
2.4.19 | 1,268 | 4/3/2023 | |
2.4.18 | 5,907 | 8/17/2022 | |
1.3.17 | 7,670 | 9/9/2021 | |
1.3.16 | 314 | 9/6/2021 | |
1.2.15 | 351 | 9/4/2021 | |
1.2.14 | 310 | 8/21/2021 | |
1.2.13 | 303 | 8/13/2021 | |
1.2.12 | 346 | 8/5/2021 | |
1.2.11 | 351 | 8/1/2021 | |
1.2.10 | 305 | 7/19/2021 | |
1.2.9 | 336 | 7/19/2021 | |
1.2.8 | 372 | 7/19/2021 | |
1.2.7 | 403 | 7/19/2021 | |
1.2.6 | 357 | 7/17/2021 | |
1.1.4 | 606 | 7/11/2021 | |
1.0.3 | 344 | 7/8/2021 | |
1.0.2 | 375 | 7/6/2021 | |
1.0.1 | 388 | 7/4/2021 |
Version 2.4.22: Removed injection of navigation manager and use a helpr to get the correct path.
Version 2.4.21: Implement IAsyncDisposable. Add Enumeral for the event actions. Use the enumeral in al events call back. Fire HttpClient dispose when object are disposed.
Version 2.4.20: Update Microsoft.AspNetCore.Components.Web to version 6.0.20 and removed dependency from Microsoft.AspNetCore.JsonPatch to version.
Version 2.4.19: Fixed control exception when dispose the script reference in Blazor Server when is used from MVC project.
Add default error message label if the programmer don't set the event callback.
Version 2.4.18: Update to NET 6 and improve MultipartFormDataContent to avoid null references.
Version 1.2.12: Change to virtual all HttpClient methods for can use your own implementation.
Version 1.2.13: Small change in a default css about drag and drop.
Version 1.2.14: Add parameter AutoUpload to set upload the file after selection. Required set TargetToPostFile parameter too.
Version 1.2.15: Add InputFileException to encapsulates exception generated when upload file
Version 1.3.16: Add paste function. Change javascript file and how to manage the file
Version 1.3.17: Checking possible issue when publish with DragAndDrop.js is missing