Permalänk
Medlem

Gömma bildlänkar i PHP?

Hallå!

Jag vill gömma bildlänkar i min källkod, tex bilder/design/test.jpg -> test.jpg

Har provat denna koden men den vill inte läsa min "image directory" :/

Scriptet jag försöker köra: http://www.knowledgesutra.com/discuss/ttfpsi-hide-real-url-im...

$ext = $_REQUEST["type"]; $filename = $_REQUEST["fl"]; /* $img is the directory where all your images are stored */ $img = "images/"; /* Firstly let's see if the variables have information in them */ if (!$ext) { echo "Could not find appropiate information"; exit; } if (!$filename) { echo "Could not find appropiate information"; exit; } if (!$img) { echo "Could not find appropiate information"; exit; } /* Extensions should be shown as numbers in the url for good protection. We will now redefine $ext matching the appropiate number from requested variable "type" */ if ($ext == 1) { $ext = "jpg"; } else if ($ext == 2) { $ext = "gif"; } else if ($ext == 3) { $ext = "png"; } /* The filename is not shown as numbers so we now have the "ingredients" needed to show the image. Now lets see if the image exists */ if (!file_exists($img . $filename . "." . $ext)) { echo "Could not find image"; exit; } /* Now lets show the image. This is just a simple include statement */ include $img . $filename . "." . $ext;

Taggen i HTML

<img src="/img.php?fl=filename&type=1" alt="Image">

Visa signatur

▩ Monitor: ASUS Swift 27" @ 1440p/165Hz ▩ CPU: Ryzen 7700X ▩ Cooling: Corsair H170i ELITE 420mm ▩ GPU: MSI 3080 Ti SUPRIM X ▩ Memory: Corsair 32GB DDR5 Vengeance ▩ Motherboard: ASUS Crosshair X670E Hero ▩ M.2: Samsung 980 Pro ▩ PSU: Corsair HX1200 ▩ Chassi: Corsair 7000X ▩ Geekbench 6: 2903 ▩ Time Spy: 19 340

📷 Mina fotografier
👍 SweClike - Synligare färg på dina likes

Permalänk
Inaktiv

Du får nog förklara det lite bättre, vad är det som inte fungerar?

Och varför vill du inte visa länkarna till bilderna?