בעיה בהורדת קובץ לשרת
-
יש לי את הקוד הזה
<?php ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); //set_time_limit(0); $fileUrl = 'https://gtfs.mot.gov.il/gtfsfiles/israel-public-transportation.zip'; $destinationPath = '/var/www/shmuelsh.ovh/zips/israel-public-transportation.zip'; $ch = curl_init($fileUrl); $fp = fopen($destinationPath, 'w'); curl_setopt($ch, CURLOPT_FILE, $fp); curl_setopt($ch, CURLOPT_TIMEOUT, 30); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); if(curl_exec($ch) === false) { echo 'cURL Error: ' . curl_error($ch); } else echo 'הקובץ יורד בהצלחה'; curl_close($ch); fclose($fp); ?>
כשאני מפעיל את זה אני מקבל
cURL Error: OpenSSL SSL_read: Connection reset by peer, errno 104אני רואה שהקובץ נוצר - בגודל 0 bytes...
מה הבעיה?
-
-
@yossiz צודק... שכחתי שכבר דנתי בזה...
עכשיו ניסיתי להשתמש במה ש @dovid נתן לי שם, אך הקובץ לא יורד לי<?php ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); set_time_limit(0); $fileUrl = 'https://gtfs.mot.gov.il/gtfsfiles/israel-public-transportation.zip'; $options = array( 'http' => array( 'header' => "Accept-language: he\r\n" . "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36\r\n" ), 'ssl' => array( 'verify_peer' => false, 'verify_peer_name' => false ) ); $content = file_get_contents($fileUrl, false, stream_context_create($options)); $file = file_put_contents("israel-public-transportation.zip", $content); echo "בוצע!";
עובר אפילו שתי דקות והקובץ לא מתחיל לרדת שם
מה הבעיה עכשיו?