6

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 3

9

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

Sign up to request clarification or add additional context in comments.

Comments

3

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>

Comments

2

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.

1 Comment

Please don't use link only answer. Please provide some example with context. In the future the link may not work, and your answer would be useless

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.