diff --git a/app/command/DataMigration.php b/app/command/DataMigration.php index 8fc74105..44cd2c7d 100644 --- a/app/command/DataMigration.php +++ b/app/command/DataMigration.php @@ -38,15 +38,15 @@ class DataMigration extends Command // $this->productCategory(); // 迁移文章 - $this->migrateArticle([ - 1 => 2, - 2 => 3, - 33 => 4, - 36 => 5, - 16 => 7, - 31 => 8, - 32 => 9 - ]); + // $this->migrateArticle([ + // 1 => 2, + // 2 => 3, + // 33 => 4, + // 36 => 5, + // 16 => 7, + // 31 => 8, + // 32 => 9 + // ]); // 迁移faq // $this->migrateFaq(); @@ -258,12 +258,19 @@ class UploadMannager } $url = self::DOWNLOAD_BASE_API . \think\helper\Str::substr($file_name, mb_strpos($file_name, $need) + mb_strlen($need)); } else { - $url = self::DOWNLOAD_BASE_API . $file_name; + $url = self::DOWNLOAD_BASE_API . str_replace(" ", "%20", $file_name); } $file_path = self::DOWNLOAD_TEMP_PATH . $file_name; - $file = file_get_contents($url); - $dir = dirname($file_path); + $opts = [ + 'http' => [ + 'method' => 'GET', + 'header' => 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64)' + ] + ]; + $context = stream_context_create($opts); + $file = file_get_contents($url, false, $context); + $dir = dirname($file_path); if (!is_dir($dir)) { mkdir($dir, 0777, true); }