I'm using the code below to download a zip file from another server which contains over 1,000 images. The source zip file is being downloaded and created / copied to my server, but the code seems to stop at that point. The echo output from the if else below doesn't even display.
I originally had the CURLOPT_TIMEOUT set to 240, but that was not long enough. I would get the curl timeout error. With the zip file being near 100MB I figured it would take about 15 minutes to complete. So I set CURLOPT_TIMEOUT set to 1200 since the source zip size will vary from day to day.
Any idea as to why it stops working? Is there a setting that needs to be changed?
$source_photos_file = 'source_photos_file.zip';
$curl = curl_init();
$destination_photos_file = fopen($_SERVER['DOCUMENT_ROOT'].'/files/photos.zip', 'w');
curl_setopt($curl, CURLOPT_URL, FTP_URL.$source_photos_file); #input
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($curl, CURLOPT_TIMEOUT, 1200);
curl_setopt($curl, CURLOPT_FILE, $destination_photos_file); #output
if (curl_exec($curl) === false)
{
echo '<p>Curl error: ' . curl_error($curl). ' - error # '.curl_errno($curl).'</p>';
}
else
{
echo '<p>Done without any errors</p>';
}
curl_close($curl);
fclose($destination_photos_file);
$photos_unzip_result = shell_exec('unzip -P password '.$_SERVER['DOCUMENT_ROOT'].'/files/photos.zip -d '.$_SERVER['DOCUMENT_ROOT'].'/files/pics_test/');