Hej,
Chciałbym pobrać plik z zewnętrznego serwera i zapisać go u siebie.
Mam taki kod:
try {
$url = "http://opendata.geoportal.gov.pl/prg/adresy/PRG-punkty_adresowe.zip";
exec('wget -O -v --debug import/data.zip '.$url.' 2>&1', $output);
echo '<pre>';
print_r($output); // to see the response to your command
echo 'Download complete';
}
catch (Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "\n";
}
Response:
Array
(
[0] => DEBUG output created by Wget 1.21.2 on linux-gnu.
[1] =>
[2] => Reading HSTS entries from /var/www/.wget-hsts
[3] => URI encoding = 'ANSI_X3.4-1968'
[4] => converted 'http://import/data.zip' (ANSI_X3.4-1968) -> 'http://import/data.zip' (UTF-8)
[5] => --2023-04-14 13:49:41-- http://import/data.zip
[6] => Resolving import (import)... failed: No address associated with hostname.
[7] => wget: unable to resolve host address 'import'
[8] => URI encoding = 'ANSI_X3.4-1968'
[9] => converted 'http://opendata.geoportal.gov.pl/prg/adresy/PRG-punkty_adresowe.zip' (ANSI_X3.4-1968) -> 'http://opendata.geoportal.gov.pl/prg/adresy/PRG-punkty_adresowe.zip' (UTF-8)
[10] => --2023-04-14 13:49:42-- http://opendata.geoportal.gov.pl/prg/adresy/PRG-punkty_adresowe.zip
[11] => Resolving opendata.geoportal.gov.pl (opendata.geoportal.gov.pl)... 91.223.135.201
[12] => Caching opendata.geoportal.gov.pl => 91.223.135.201
[13] => Connecting to opendata.geoportal.gov.pl (opendata.geoportal.gov.pl)|91.223.135.201|:80... connected.
[14] => Created socket 4.
[15] => Releasing 0x00005635f7804e20 (new refcount 1).
[16] =>
[17] => ---request begin---
[18] => GET /prg/adresy/PRG-punkty_adresowe.zip HTTP/1.1
[19] => Host: opendata.geoportal.gov.pl
[20] => User-Agent: Wget/1.21.2
[21] => Accept: */*
[22] => Accept-Encoding: identity
[23] => Connection: Keep-Alive
[24] =>
[25] => ---request end---
[26] => HTTP request sent, awaiting response...
[27] => ---response begin---
[28] => HTTP/1.0 302 Moved Temporarily
[29] => Location: https://opendata.geoportal.gov.pl/prg/adresy/PRG-punkty_adresowe.zip
[30] => Connection: Keep-Alive
[31] => Content-Length: 0
[32] =>
[33] => ---response end---
[34] => 302 Moved Temporarily
[35] => Registered socket 4 for persistent reuse.
[36] => Location: https://opendata.geoportal.gov.pl/prg/adresy/PRG-punkty_adresowe.zip [following]
[37] => ] done.
[38] => URI content encoding = None
[39] => converted 'https://opendata.geoportal.gov.pl/prg/adresy/PRG-punkty_adresowe.zip' (ANSI_X3.4-1968) -> 'https://opendata.geoportal.gov.pl/prg/adresy/PRG-punkty_adresowe.zip' (UTF-8)
[40] => --2023-04-14 13:49:42-- https://opendata.geoportal.gov.pl/prg/adresy/PRG-punkty_adresowe.zip
[41] => Found opendata.geoportal.gov.pl in host_name_addresses_map (0x5635f7804e20)
[42] => Connecting to opendata.geoportal.gov.pl (opendata.geoportal.gov.pl)|91.223.135.201|:443... connected.
[43] => Created socket 5.
[44] => Releasing 0x00005635f7804e20 (new refcount 1).
[45] => Initiating SSL handshake.
[46] => SSL handshake failed.
[47] => OpenSSL: error:0A000152:SSL routines::unsafe legacy renegotiation disabled
[48] => Closed fd 5
[49] => Unable to establish SSL connection.
)
Mam php 8.1
Plik się nie pobiera :(
Wie ktoś może jak naprawić ten problem?