faça algo como que deve resolver seu problema
if($fp=fopen($img, 'r'))
{
........
}
fclose($fp);
> MSN: lau...@hotmail.com <mailto:lau...@hotmail.com>
> >
Já tentou usar a função file_exists?
<?php
$filename = '/caminho/para/qualquer.txt';
if (file_exists($filename)) {
print "O arquivo $filename existe";
} else {
print "O arquivo $filename não existe";
}
?>
Att,
Tailor.
<?php
$file = fopen ("http://www.example.com/", "r");
if (!$file) {
echo "<p>Incapaz de abrir arquivo remoto.\n";
exit;
}
fclose($file);
?>
Att,
Tailor.
cbov@monza /tmp $ cat teste.php
<?
function teste($img)
{
echo $img." - ";
if($fp=fopen($img, 'r'))
{
echo "existe\n";
return true;
}
else
{
echo "nao existe\n";
return false;
}
fclose($fp);
}
teste("http://www.google.com/images/logo_sm.gif");
teste("http://www.google.com/images/NAOEXISTElogo_sm.gif");
teste("teste.php");
?>
cbov@monza /tmp $ php teste.php
http://www.google.com/images/logo_sm.gif -
Warning: fopen(): URL file-access is disabled in the server
configuration in /tmp/teste.php on line 5
Warning: fopen(http://www.google.com/images/logo_sm.gif): failed to open
stream: no suitable wrapper could be found in /tmp/teste.php on line 5
nao existe
http://www.google.com/images/NAOEXISTElogo_sm.gif -
Warning: fopen(): URL file-access is disabled in the server
configuration in /tmp/teste.php on line 5
Warning: fopen(http://www.google.com/images/NAOEXISTElogo_sm.gif):
failed to open stream: no suitable wrapper could be found in
/tmp/teste.php on line 5
nao existe
teste.php - existe
======================
mudei a configuração allow_url_fopen de Off para On no php.ini
======================
cbov@monza /tmp $ php teste.php
http://www.google.com/images/logo_sm.gif - existe
http://www.google.com/images/NAOEXISTElogo_sm.gif -
Warning: fopen(http://www.google.com/images/NAOEXISTElogo_sm.gif):
failed to open stream: HTTP request failed! HTTP/1.0 404 Not Found
in /tmp/teste.php on line 5
nao existe
teste.php - existe
Warning: fopen( http://www.google.com/images/NAOEXISTElogo_sm.gif):
Grato
André P. Santos
<?
$imagem = @imagecreatefromJpeg ($_GET['imagem']);
if (!$imagem) { /* See if it failed */
$imagem = imagecreate(100, 100); /* Create a blank image */
$bgc = imagecolorallocate($imagem, 255, 255, 255);
$tc = imagecolorallocate($imagem, 0, 0, 0);
imagefilledrectangle($imagem, 0, 0, 100, 100, $bgc);
/* Output an errmsg */
imagestring($imagem, 1, 12, 45, "Não encontrada.", $tc);
};
Header("Content-type: image/JPEG");
ImageJpeg($imagem);
ImageDestroy($imagem);
?>
________________________________________________
Message sent using UebiMiau 2.7.9