M
M
mediagenia2012-01-27 22:42:36
PHP
mediagenia, 2012-01-27 22:42:36

How to parse images that the server gives like this:

The server gives the image in this way:
www.domain.ru/h_11257dd5bf05a39403cb8a4b4b52cb2a

I'm trying to get the image using file_get_contents();
How to do it? Substituting the url directly, I get a file with 180 characters html

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
DevMan, 2012-01-27
@mediagenia

Most likely you have something with the settings:

DevMan /Users/devman
1014 ~ % php -a                                              2012-01-27 22:06:41 devman ttys004
Interactive shell

php > $i = file_get_contents( 'http://www.petshop.ru/netcat_files/115/135/h_11257dd5bf05a39403cb8a4b4b52cb2a' );
php > file_put_contents( 'i.jpg', $i );
php > exit;
DevMan /Users/devman
1015 ~ % ls -la | grep i.jpg                                 2012-01-27 22:07:27 devman ttys004
-rw-r--r--   1 devman  staff  87878 Jan 27 22:07 i.jpg
DevMan /Users/devman
1016 ~ % head -n2 i.jpg                                      2012-01-27 22:07:40 devman ttys004
????WExifII?
?????(1?2CanonCanon EOS-1DS??-'??-'Adobe Photoshop CS5 Windows2012:01:17 17:27:24??j??r"?'?d?0220?z????
...

It is better to take it with curl: you can get the server response headers there.

E
edogs, 2012-01-27
@edogs

Everything works without problems with the usual file_get_contents.
Ping the domain from the hosting, maybe it sends you to the wrong place? (IP 109.124.94.226).
Then it is necessary to kick a hoster.

B
Boris Syomov, 2012-01-28
@kotomyava

Oh, you don't have long to parse. =)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question