I been trying to create a simple php script to covert a dynamic url generated by another php into an image but all i get is a blank page, does anybody know why this is not working?
<?php
include('icecast.php');
$cover = ($stream['artist']['top_albums']['0']['image']['3']);
header('Content-Type: image/jpeg');
readfile('$cover');
?>
I have try so many different ways but i still get the same result.
Well, at least you are trying to use not variable $cover
but literal string '$cover'
.
It is strings have to be delimited by quotes, but variables should be accessed without them.
You are using '$cover'
when it should be just $cover
readfile($cover);
Also make sure $cover has complete file name, with the extension, and add
header('Content-Length: ' . filesize($cover));
Also do this:
header('Content-Type:image/jpeg');
header('Content-Length: ' . filesize($cover));
readfile($cover);
Use both headers, alo verify if your file has jpeg type.... And make sure no output till headers, absolutely none. No echo. And as content type is image, there should be no output other than the file at all!!!
this worked for me:
The important points is that you must send a Content-Type header. Also, >you must be careful not include any extra white space (like newlines) in >your file before or after the tags.
As suggested in the comments, you can avoid the danger of extra white >space at the end of your script by omitting the ?> tag: