Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

136
Views
Not allowed to load local resource - while trying to get full path

It is a Blazor project

Below is the Index.razor:

//A file selector that returns only file name instead of full path
<InputFile id="flpicker" OnChange="@OnInputFileChange" multiple />
<p>@fileName</p> // displays file name that was picked (i.e.example1.json)

//below four line passes file name to JS
@{
var passFileName = @fileName;
}
<input type="hidden" id="PassingFileNameToJS" value=@passFileName>

@code{
  string fileName;
  //below function gets file name
  private async Task OnInputFileChange(InputFileChangeEventArgs e)
  {
    foreach (var File in e.GetMultipleFiles(e.FileCount))
    {           
        var Name = File.Name;
        fileName = Name;
    }
} 
}

Below is the index.js: Full path of file selected.

var filePath= "file:///C:/JsonFiles/" + document.getElementById("PassingFileNameToJS").value;

'document.getElementById("PassingFileNameToJS")' provides file name "example1.json". But in order to get full path, I hard to hardcode values.

When I use this above full filepath for opening file, throws error as "Not allowed to load local resource: file:///C:/JsonFiles/example1.json".

Is it possible to get full path without hardcoding values like above? Any help would be appreciated.

about 4 years ago · Santiago Gelvez
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!