I'm trying to script the download of a large file, but the script generates a 404 error.
// Get file and save to raw.csv
$url = 'http://spam-ip.com/csv_dump/spam-ip.com_'.date("m-d-Y").'.csv';
//File to save the contents to
$fp = fopen ('raw.csv', 'w+');
//Here is the file we are downloading, replace spaces with %20
$ch = curl_init(str_replace(" ","%20",$url));
curl_setopt($ch, CURLOPT_TIMEOUT, 0);
curl_setopt($ch, CURLOPT_FILE, $fp);
$data = curl_exec($ch);//get curl response
//done
curl_close($ch);
fclose($fp);
The remote file exists (it's updated every day throughout the day), and I can access it directly via browser. But attempts to access via curl or file_get_contents() (I've tried it both ways) produce 404 errors. Any suggestions on a fix?