Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

312
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda