Search code examples
phpimageurlimageurl

How to get imageurl from the url? So it can show the image I want in the page


So I have this page .html , .php, whatever, It's a page with my logo, some ads, menus etc. I want this page to show the image I want, Let's say I have /images/image1.jpg and I want to sent it to someone, but I want that person to see it in my website so I would so something like mypage.com/example.php(somecodehere?)/images/image1.jpg

And it would open example.php (or .html) with image1.jpg displaying where I had my code (let's say in the middle)

Any simple way to do this?

Thanks


Solution

  • You should use the $_GET to get the image:

    www.exapmle.com/page.php?imagename=image1.jpg => simple example for the page.php code
    <?php
       echo "<img src=\"{$_GET["imagename"]}\">";
    ?>
    

    Be aware that this is a dangerous code and you should always check the input from the user.