Reputation: 133
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>
Upvotes: 6
Views: 5054
Reputation: 21
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.
Upvotes: 2
Reputation: 41
see these two file are available or not on _host.cshtml
<script src="_content/BlazorInputFile/inputfile.js"></script>
<script src="_content/Blazored.Modal/blazored.modal.js"></script>
Upvotes: 3
Reputation:
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
Upvotes: 9