Could not find 'BlazorInputFile' in 'window'

Viewed 4235

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

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>

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:

https://raw.githubusercontent.com/SteveSandersonMS/BlazorInputFile/master/BlazorInputFile/wwwroot/inputfile.js

Finally, in your _Host.cshtml file, reference it like this:

Example

and ready. Bug fixed.

Related