Вот код:
Код: Выделить всё
$sourceURL = 'https://www.gencon.com/downloads/events.xlsx';
$targetFilename = 'GenConEvents.xlsx';
if (file_exists($targetFilename))
{
unlink($targetFilename);
}
$c = curl_init();
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($c, CURLOPT_URL, $sourceURL);
$contents = curl_exec($c);
curl_close($c);
echo "File returned " . strlen($contents) . " bytes\n\n";
if (!file_put_contents($targetFilename, $contents))
{
echo "Error downloading the spreadsheet\n\n";
return;
}
Код: Выделить всё
File returned 0 bytes.
Error downloading the spreadsheet
URL-адрес действителен.
Если я заменю файл XLSX в $sourceURL, скажем, файлом CSV или HTML, он будет работать нормально. С другой стороны, у ZIP-файла та же проблема с нулевым байтом.
Мобильная версия