I am trying to save some images from different links which are saved in a .txt but I'm getting an error
failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found
If I open the url it works and if I paste the url directly into the code it works also. But why doesn't it work if I want to take the url from the txt file?
<?php
$links = file('download.txt');
foreach ($links as $link) {
$path = "C:/xampp/htdocs/download/sp/". basename($link);
$image = file_get_contents($link);
file_put_contents($path,$image);
}?>