0

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.

3
  • 2
    Please paste the complete code.. Commented Dec 25, 2012 at 18:59
  • In the answers below you are saying "The output only shows a lot of symbols and letters" - how are you putting the image on a page? - is this an HTTP call or ajax? This is why we ask for more code. Ambiguity doesn't help resolve problems. Commented Dec 25, 2012 at 20:27
  • i Already added a link to the projects page I'm not being ambiguity! Commented Dec 25, 2012 at 20:39

3 Answers 3

2

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.

Sign up to request clarification or add additional context in comments.

Comments

1

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:

taken from this answer

Comments

0

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!!!

4 Comments

Your provided solution kind works the only problem now is the image is not displaying the way it should be, the image is being displaying as symbols and letters.
I don't want to disclose the file codes since is not my creation but i can write a link to it so you can see what is going on on icecast.php [link]code.google.com/p/icecast-now-playing-script/source/browse/…
remove all headers... use echo $cover...and see what is happening. If yoy are getting path properly or not
the output is the url to the image

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.