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.
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.
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
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';