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

311
Views
How to Render Raw a HTML Image in React That is Stored Locally on a Server?

I'm trying to display a raw HTML webpage with an image that is stored locally on server in my network.

    module.exports = `
<html>

<img src="file://thisLocalServer/image.jpg" />

</html>`

When I try to display this image however, it displays the default blank placeholder image. This is my App.js file.

var __html = require('./html.test.js');
var template = { __html: __html}

    render() {
        return(
            <span dangerouslySetInnerHTML={template}/>
        );

If I try setting the image source as a normal link like https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png then it appears to work fine.

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

To fix this download the image, put it in the folder with the index.html or a subfolder with the index.html and put the following link:

<img src="foldername/image-name.format">

Or via javascript:

document.location.pathname + '/foldername/image-name.format';
about 4 years ago · Juan Pablo Isaza Report

0

In short, with the code above, no image will ever be shown.

Details:

There are several issues with the src attribute of the <img> tag.

  • 1st, the src is not recommended to use file:// protocol
  • 2nd, it looks like you are missing a slash, it could be file:///filesystem/path/to/img.jpg

But in my exp, even you fix the 2nd one, your image will not load because of the 1st one. This is a security reach if the access to a webpage (through http or https protocol) is able to know the filesystem of the server.

about 4 years ago · Juan Pablo Isaza Report
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!