Show Image from a PHP remote server

1

What kind of friends my problem is this.

I have a Server A where I have images, I have a server B which is the server of the applications, both servers are connected to a network and server A has a folder shared with server B with the letter V:

If I want to show a photo in my browser access like this:

$ubicacion = 'V:/Fotos/imagen.jpg';
$content = file_get_contents($ubicacion);
header("Content-Type: image/jpeg");
echo $content;

I do not know if it's server A permission issues or there's a way to display the photo and save it to server B

    
asked by Ricardo Garcia 09.06.2017 в 18:22
source

1 answer

1

The photo that you try to show if it is exactly how you leave the code will not work since it is the PHYSICAL route ( V:/Fotos/imagen.jpg ) since you are on different servers. What you have to get is the URL of the image, it should be something like https://tuservidor.com/fotos/imagen.jpg

I have the same operation you describe, what you can do:

  • In the server database, in a Config table I have a column that is URL_Images.

  • Within your project, in the Config file you have a variable with the value of the URL.

On server B, which is where you consume the data, you should arm the URL

$url_images = $this->config->item('url_imagen');
$imagen = $url_images + $imagen_mostrar;
    
answered by 09.06.2017 в 18:29