display an image through the URL

Asked

Viewed 26 times

-1

I wonder if it is possible to display an image in an HTML code where only its link is stored in a PHP variable. I tried to do it the way I thought it was obvious but I didn’t succeed.

<!DOCTYPE html>
<html>

<?php
$imagem = 'http://www.mediafire.com/view/wg0156qxjkzulv3/premium.png/file ';
?>

<img src="<?php echo $imagem;?>" alt="">
</html>

1 answer

2

Hello, Matheus!

Your code is correct and this is possible. What is wrong is the code of the image you used. If you open this link in the browser and right click on the image will appear: Copy Image URL. This is the URL you need to use. What you used is the entire Mediafire page, including share button, login... Your correct code would look like this:

<!DOCTYPE html>
<html>

<?php
$imagem = 'http://www.mediafire.com/convkey/c9df/wg0156qxjkzulv3zg.jpg';
?>

<img src="<?php echo $imagem;?>" alt="">
</html>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.