V
V
Vladimir Pilipchuk2018-04-07 22:51:50
PHP
Vladimir Pilipchuk, 2018-04-07 22:51:50

How to display image via php script without changing url?

Interested in the question, is it possible with the help of a web server, php and tricks to display an image in a "wrapper".
Given: there is an image on the server (nginx), it is available at the URL //server.domain/image.png and is displayed correctly.
I want to: when accessing the URL of an image, display not only the image itself, but also a menu bar at the top of the screen. Ideally, a stylized page, but without a redirect to page.php. That is, when accessing //server.domain/image.png, it is not the image itself that opens, but the page containing this same /image.png, but the URL remains //server.domain/image.png

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladimir, 2018-04-09
@SLIDERWEB

location /img/pilipchuk {
rewrite ^/img/pilipchuk/(.*)$ /obertka/index.php?url=$1 last;
try_files $uri @fallback;
}
location /img/getPilipchuk {
rewrite ^/img/getPilipchuk/(.*)$ /obertka/load.php?url=$1 last;
try_files $uri @fallback;
}
/public_html$ ls obertka/
index.php load.php
folder with images
public_html$ ls img/pilipchuk/
logo.png
index.php files

<?php
print_r($_GET);

echo "<div style='width:100%;'>Hello VOVAN</div><br>";
echo "<div><img src='/img/getPilipchuk/{$_GET['url']}'></div>";
?>

load.php
<?php
echo file_get_contents("./../img/".$_GET['url']);
?>

At the URL somedomain.com/img/pilipchuk/logo.png
we see
5acadf4b4e9a0654224768.png

B
Barmunk, 2018-04-07
@Barmunk

//server.domain/image.php?name=image.png and forward

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question