Fread( doesnt seem to return data in PHP

Hmm

$r = fopen("images/nowplaying.png", 'r');
if ($r !== false) 
{
    $textXML = fread($r,filesize("images/nowplaying.png"));
    fclose($r);
} else {
    fclose($r);
    ReturnError(500, 'Failed to write artwork to a file.');   
}

it seems to only read one image here “images/nowplaying_artwork_2.png” why is this different chmods are the same ?

If you need help, you need to write more clearly.
Please fill up according to template

KangJL it didnt have one ?

The template should come up when you create a new topic. Strange…

idk it does one image but not other http://www.deniserose.epizy.com/create_SQL.php if the images chmods are the same and the are in same location should they not do same thing ?

I see this

Good luck!

I see this

image

Is the file corrupted?

This looks ok

image

2 Likes

The code you’re using only reads the image from images/nowplaying.png, not images/nowplaying_artwork_2.png? Of course, if you’re writing something to file A, then it doesn’t update file B. Or did you edit/simplify the code sample for this question?

Also, I would personally just use file_get_contents("images/nowplaying.png") so you don’t have to deal with the tape drive style API of fopen, but this should be fine too.

6 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.