...
|
...
|
@@ -372,19 +372,26 @@ public function websiteHtmlHandle($zip_count, $domain) |
|
|
*/
|
|
|
public function downLoadFile($url)
|
|
|
{
|
|
|
// 创建一个流上下文,设置 SSL 选项
|
|
|
$context = stream_context_create([
|
|
|
"ssl" => [
|
|
|
"verify_peer" => false, // 不验证对等证书
|
|
|
"verify_peer_name" => false, // 不验证对等证书名称
|
|
|
],
|
|
|
]);
|
|
|
$savePath = public_path();
|
|
|
if (!file_exists($savePath)) {
|
|
|
mkdir($savePath, 0777, true);
|
|
|
}
|
|
|
$targetFile = $savePath . '/' . basename($url);
|
|
|
if (!file_exists($targetFile)) {
|
|
|
$file = fopen($targetFile, 'w');
|
|
|
$file = fopen($targetFile, 'w', false, $context);
|
|
|
fclose($file);
|
|
|
chmod($targetFile, 0755);
|
|
|
}
|
|
|
|
|
|
$remoteFile = fopen($url, 'rb');
|
|
|
$localFile = fopen($targetFile, 'wb');
|
|
|
$remoteFile = fopen($url, 'rb', false, $context);
|
|
|
$localFile = fopen($targetFile, 'wb', false, $context);
|
|
|
if ($remoteFile && $localFile) {
|
|
|
while (!feof($remoteFile)) {
|
|
|
fwrite($localFile, fread($remoteFile, 1024 * 8), 1024 * 8);
|
...
|
...
|
|