Array ("header" = "Referer:". $refer)); $context =stream_context_create ($opt); $file _contents = file_get_contents ($url, False, $context); Echo $file _contents; >
I want to forge a referer, and then use file_get_contents to get the picture to show,
But the display is garbled, how to solve?
Reply to discussion (solution)
No problem with the code!
Remove the BOM header from the program file
If you want the entire file to be output as a picture, precede it with a sentence: header ("Content-type:image/png");
You try the method of the second floor!
Plus go, but the same is garbled
Garbled page, cut a picture to see
This is the only way to add a type declaration
This is definitely not your code to produce!
This is a high version of JPEG not PNG
And this format in the lower version of the browser is not open, can only be garbled or a fork
Sorry, my picture URL input is not the same as the question, but the problem is still not resolved
I'm sorry--I'm too quick to read what you said.
It's OK to browse with chrome, thanks.
The header of the picture is added to echo the stream data directly.
If you know each other's picture format you can simply save the data stream each time to generate a picture locally to display it.
You use Notepad to open the picture is like this, with the header Content-type try