0

何らかの理由で、以下の画像をダウンロードしようとすると、このエラーが発生します。2つの画像のうち1つがこのエラーを返しています。

Warning: file_get_contents(http://www.ndcontent.com/rk/mikesapartment/faces/marica.jpg ) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in C:\xampp\htdocs\tgp\index.php on line 22

私が使用するコードは次のとおりです:($ randは16桁の整数で、ダウンロードするたびに変更されます)

file_put_contents('img/'.$rand.'.jpg', file_get_contents($img_url));    
4

1 に答える 1

0

URL が空白で終わっているようです

(http://www.ndcontent.com/rk/mikesapartment/faces/marica.jpg )
                                                            ^

その結果、404 Not Found エラーが発生します。

解決策:trim最初に URL

于 2013-01-31T00:23:27.597 に答える