hello, I have a simple PHP script that is thought to download jpg file from url and save it to my server, but it is not working, can you help me to solve it?
$image = explode("\n", $_POST['images']);
for ($i = 0; $i < count($image); $i++){
if (substr($image[$i], 0, strlen($this->host) - 1) != $this->host){
file_put_contents('images/'.$title_url.'_'.$i.'.jpg', file_get_contents($image[$i]));
$image[$i] = $this->host.'/images/'.$title_url.'_'.$i.'.jpg';
}
}
There is 3 files in textarea, but php downloads completely last file, but for first and second files gives me an error:
Message: file_get_contents(http://geosmiley.ge/Upload/Product/64/1.jpg ) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found
Message: file_get_contents(http://geosmiley.ge/Upload/Product/64/2.jpg ) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found