how to get an image located on another server?

0

I'm trying to show an image on a page hosted on windows server 2016, but the image is saved on another server and both servers are connected on the same network. This I do using php, html and javascript in tests I did with xampp and changing the ports showed me the image well, but now I do not know how to do it so that they are shown since the page is located on the server.

The php that gets me the images of the server is the following ...

       $ruta_img = "\\ipservidor\imagenes\imagenes_hoy\imagen1.png";
       $imagen = base64_encode(file_get_contents($ruta_img));

and this happened to a javascript function that is responsible for showing it in the section that I require.

   function mostrarImagenes(imagen1, imagen2) {
      document.getElementById('imgOne').setAttribute('src', 'data:image/jpg;base64,'+imagen1);
      document.getElementById('imgTwo').setAttribute('src', 'data:image/jpg;base64,'+imagen2);      
   } 

I do not use any framework is common php.

    
asked by Alberto Rojas 20.04.2017 в 00:00
source

1 answer

0

That the teams are in the same network provides more information, since server 2 could have a firewall configured to filter (and ignore) any request it receives.

A question is: server2 is a web server ?, because if so, there should be no major problem, and the argument of file_gets_content should be http://ip_servidor/.../nom_arch.png .

Now, if server2 is not a web server, a related question whose answer you could use is how would you (using the window console) copy the file available on server2 to a directory on server1? The route you use to achieve this is the same as you should use for your php.

    
answered by 24.04.2017 в 21:52