Output header image header PHP vs Address Forwarding to binary in fs

I'm trying to determine if I should just right

1) so that PHP receives an image with a binary and an output image (with a header as an image), for example:

/* $image = ... insert curl function to fetch image */

header('Content-Type: image/png');

echo $image;

or if I have

2) the header is redirected to the image URL path

header('Location: http://domain.com/pathtoimage/image.png');

Some initial questions:

In the first case, this will mean any overhead associated with the fact that PHP must have an image in memory to display it?

In the second case, will this lead to any errors on clients that somehow cannot follow the PHP header redirection?

+5
source share
1 answer

location → location, . :

if (file_exists($file)) {
        header('Content-Type: image/png');
        readfile($file);
        exit;
    }

.

0

All Articles