Shub-Niggurat (heath247) wrote in php,
Shub-Niggurat
heath247
php

file_exists and is_file always false

Please help me with this, I'm trying to create a handler for a 404 error, and i feel like I'm close, but my if statement always returns a false. Code below cut


$user = "MHeath81";
$filename = "http://ws.audioscrobbler.com/rdf/history/$user";
if (is_file($filename)) {
$fp = fopen($filename, "r");
}
else {
Header("Content-type: image/jpeg");
$im = imageCreateFromJPEG("scrobbler.jpg");
$m1 = "Last track played:";
$nomessage = "Tracks database currently unavailable";
$red = ImageColorAllocate($im, 249, 79, 79);
$white = ImageColorAllocate($im, 0, 0, 0);
ImageString($im,2,5,1,$m1,$red);
ImageString($im,3,11,95,$nomessage,$white);
ImageString($im,3,10,94,$nomessage,$red);
ImageJPEG($im, '', 90);
ImageDestroy($im);
}


Any help greatly appreciated, I feel like I'm missing something really stupid, it could even be the way I'm accessing the file using is_file or file_exists.
Subscribe
  • Post a new comment

    Error

    default userpic

    Your IP address will be recorded 

    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.
  • 16 comments