How to insert one image per parameter in the url and display it on the screen

0

I need the code to check if this parameter with the image exists, if it exists, I have to display it on the screen. How can I do it?

Note: The parameter with the image must be passed by the user in the url. That is, with GET.

    
asked by anonymous 23.03.2015 / 17:51

2 answers

6
if (isset($_REQUEST['url_da_imagem']))
{
    echo '<img src="'.$_REQUEST['url_da_imagem'].'">';
}

Instead of $_REQUEST you can use $_GET , it $_REQUEST works for both GET and POST, so in case you need to receive the URL by POST too, without having to change your code.

Edit:

Ah, the URL would look like this: link

    
23.03.2015 / 18:03
3

I imagine that cURL can help.

$foto = $_GET['imagem_url'];

$ch = curl_init($foto);
curl_exec($ch);
$HTTPCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

if($HTTPCode == '200'){
    echo '<img src=".'$foto.'">';
}
else 
    echo 'Imagem não encontrada';
    
23.03.2015 / 18:14