Does the Laravel filesystem support this (especially for functions such as copy)?
file_get_contents
If the HTTPS Web site encounters an SSL validation failure , the error cannot be ignored.
Reply content:
Does the Laravel filesystem support this (especially for functions such as copy)?
file_get_contents
If the HTTPS Web site encounters an SSL validation failure , the error cannot be ignored.
You can use Guzzlehttp.
Plus:
Use Guzzlehttp\client;use guzzlehttp\exception\guzzleexception;
$client = new Client ([' verify ' = false]); Ignore SSL Error $response = $client->get ($url, [' save_to ' = Public_path ($file)]); Save remote URL to file
Can be written with try catch.
Guzzlehttp gets the remote resource. Storage handles file storage.
try { $client = new \guzzlehttp\client (); $data = $client->request (' Get ', ' http://xxxx ')->getbody ()->getcontents (); Storage::d ISK (' local ')->put (' filename ', $data);} catch (\guzzlehttp\requestexception $e) { echo ' fetch fail ';}
The problem with SSL certificate validation failure is that you do not have the latest list of CA certificates locally, just download one.
$client = new \guzzlehttp\client ($url, [ ' curl.options ' = = [ curlopt_ssl_verifypeer=>2, curlopt_ Ssl_verifyhost=true, ]]);
You can do it with curl.
File_put_contents ('/tmp/logo.gif ', file_get_contents (' https://www.baidu.com/img/bdlogo.gif '));
As long as your PHP adds OpenSSL support ( --with-openssl
), the file_get_contents will certainly support HTTPS.
If you are prompted with an error:
SSL operation failed with code 1. OpenSSL Error messages:
Error:14090086:ssl routines:ssl3_get_server_certificate:certificate Verify failed
Then download the Cacert.pem file, then specify it in PHP.ini, and then restart the PHP service as well:
wget Https://curl.haxx.se/ca/cacert.pemphp.ini:openssl.cafile=/path/to/cacert.pemvar_export (Openssl_get_cert_ Locations ()); Array ( ' default_cert_file ' = '/opt/phpdroid/deps/ssl/cert.pem ', ' default_cert_file_env ' = ' Ssl_cert_file ', ' default_cert_dir ' = '/opt/phpdroid/deps/ssl/certs ', ' default_cert_dir_env ' = > ' Ssl_cert_dir ', ' default_private_dir ' = '/opt/phpdroid/deps/ssl/private ', ' Default_default_cert_ Area ' = '/opt/phpdroid/deps/ssl ', ' ini_cafile ' + ', ' ini_capath ' = ', '