Roohbakhsh Masoud
Roohbakhsh Masoud

Reputation: 144

Stream_get_content not working for the second time?

I am working with a stream_get_content the first time. Everything seems ok until i tried to read the content from the stream for the second time.

if my value that pass to the stream_get_content is repeating , return empty value !?

but if my value isn't repeating everything is good!!!!

public function makeAvatar($value)
{
    $file_result = "data:image/gif;base64,";
    $file_result .= base64_encode(stream_get_contents($value));
    return $file_result;
}

Upvotes: 4

Views: 1275

Answers (1)

Japo
Japo

Reputation: 76

You can to use rewind() to reset the pointer to the beginning of the stream.

Upvotes: 6

Related Questions