Angwa Moses Angwa Moses - 1 month ago 9
PHP Question

How to stop image referring back to the parent folder

Please I've been trying my best to get this working but I can't figure it out. This is the code:

$image = $p['Photo']; ` <meta property="og:image" content="<?php echo htmlspecialchars("http://myurl.com/$image"); ?>" />`


Each time it runs, it shows http://myurl.com/../postphotos/image.png
as the output instead of http://myurl.com/postphotos/image.png

Note: post photos are the actual folder where the images are.

Answer Source
$image = preg_replace('/^\.+\//', '', $p['Photo']);
<meta property="og:image" content="<?php echo htmlspecialchars("http://uamxtreme.com/$image"); ?>" />