Я не знаю, почему возникла проблема, но вот код, который ее исправил, благодаря "NikiC", который обнаружил, что это было ", - я исправил это.
Этот код не работает
$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';
}
}
$poster = $image[0];
$images = implode("\n", $image);
Это рабочий код
$image = explode("\n", $_POST['images']);
for ($i = 0; $i < count($image); $i++){
if (substr($image[$i], 0, strlen($this->host) - 1) != $this->host){
if ($i < count($image)-1){
$kk = substr($image[$i], 0, strlen($image[$i]) - 1);
} else {
$kk = $image[$i];
}
if ($this->download($kk, 'images/'.$title_url.'_'.$i.'.jpg')){
$image[$i] = $this->host.'/images/'.$title_url.'_'.$i.'.jpg';
}else{
echo($image[$i]);
}
}
}
//****************************************************
public function download($url, $path){
if (file_put_contents($path, file_get_contents($url))){return TRUE;}else{return FALSE;}
}