1
I usually use the function file_exists of PHP to do this when I am developing remotely, but now I need to know when the image exists or not in a URL absolute of an external web server.
Editing the question to include more information:
I tested all these methods both on the local server and on a web server other than www.issam.com.br and none returns the correct value, someone knows whether it is possible?
Imagem que existe = http://www.issam.com.br/ximages/produtos/356031.jpg
Imagem que não existe = http://www.issam.com.br/ximages/produtos/356030.jpg
if(file_exists('http://www.issam.com.br/ximages/produtos/356030.jpg')){
echo"sim";
}else{
echo"nao";
}
if(file_get_contents('http://www.issam.com.br/ximages/produtos/356030.jpg')) {
echo "Existe";
}else{
echo"nao";
}
$arquivo = 'http://www.issam.com.br/ximages/produtos/356030.jpg';
$file_headers = @get_headers($arquivo);
if(!$file_headers || $file_headers[0] == 'HTTP/1.1 404 Not Found') {
echo 'Arquivo não existe.';
}else {
echo 'Arquivo existe.';
}
$arquivo = 'http://www.issam.com.br/ximages/produtos/356030.jpg';
if (!$fp = curl_init($arquivo)){
echo 'Arquivo não existe.';
}else{
echo 'Arquivo existe.';
}
PLEASE SEARCH IF THERE ARE NO ANSWERS ON THE SITE THAT ANSWER ANY QUESTIONS, I AM VERY GRATEFUL IF YOU FAVOUR THE EXISTING ANSWERS http://answall.com/q/1819/3635
– Guilherme Nascimento
Obs: was not me who denied your answer, but I have already guided you more than once on how to mark the question as duplicate
– Guilherme Nascimento
@Guilhermenascimento... thank you once again for your attention. I will endeavor not to answer before checking.
– Allan Andrade
It is not duplicated because the question is for external servers and not own or remote server as Kenny Rafael’s answer says. I had already tried this answer but it does not work. I will try these of friends Lucas Caires and Allan Andrade.
– denis
Denis, let me know if it works.
– Allan Andrade
@Remote server and external server Denis is pretty much the same thing, what do you mean by absolute URL? Would that be it
/home/user/teste/image.jpg
or would that behttp://siteexterno.com/image;jpg
or would that besmb://shared/image.jpg
. Please find more details.– Guilherme Nascimento
Soon testo Allan. Guilherme would be http://siteexterno.com/image.jpg I tested with file_exists and it didn’t work.
– denis