It gives an error Microsoft.JSInterop.JSException: Could not find 'BlazorInputFile' in 'window'. in blazor server app.
I have Installed BlazorInputFile Version="0.1.0-preview-00002". and added _
host.cshtml
<script src="_content/BlazorInputFile/inputfile.js"></script>
and also _Imports.razor file refereced
@using System.IO
@using BlazorInputFile
razor form file
<InputFile OnChange="HandleSelection"></InputFile>
3 Answers
Try this in your _Host.cshtml file?
<script src="~/_content/BlazorInputFile/inputfile.js"></script>
If that doesn't work, I have a Nuget project with a working sample project that uses a wrapper to Steve Sanderson Blazor File Input here:
Nuget: DataJuggler.Blazor.FileUpload
Source and Sample Project: https://github.com/DataJuggler/BlazorFileUpload
Comments
the same thing happened to me. I found the solution. In this page:
https://blog.stevensanderson.com/2019/09/13/blazor-inputfile/
Specifically where it says "For client-side Blazor"
Basically it is a bug, you have to create an empty js file (inputfile.js), it can be in wwwroot and paste the content of this link:
Finally, in your _Host.cshtml file, reference it like this:
and ready. Bug fixed.