正在显示
1 个修改的文件
包含
8 行增加
和
2 行删除
| @@ -79,7 +79,13 @@ class ProjectImport extends Command | @@ -79,7 +79,13 @@ class ProjectImport extends Command | ||
| 79 | //读取csv文件 | 79 | //读取csv文件 |
| 80 | $line_of_text = []; | 80 | $line_of_text = []; |
| 81 | try { | 81 | try { |
| 82 | - $file_handle = fopen($task->file_url, 'r'); | 82 | + $opts = [ |
| 83 | + 'http' => [ | ||
| 84 | + 'method' => 'GET', | ||
| 85 | + 'header' => 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.246' | ||
| 86 | + ] | ||
| 87 | + ]; | ||
| 88 | + $file_handle = fopen($task->file_url, 'r', null, stream_context_create($opts)); | ||
| 83 | while (!feof($file_handle)) { | 89 | while (!feof($file_handle)) { |
| 84 | $line_of_text[] = fgetcsv($file_handle, 0, ','); | 90 | $line_of_text[] = fgetcsv($file_handle, 0, ','); |
| 85 | } | 91 | } |
| @@ -183,7 +189,7 @@ class ProjectImport extends Command | @@ -183,7 +189,7 @@ class ProjectImport extends Command | ||
| 183 | protected function get_code_type($file) | 189 | protected function get_code_type($file) |
| 184 | { | 190 | { |
| 185 | $list = array('GBK', 'UTF-8'); | 191 | $list = array('GBK', 'UTF-8'); |
| 186 | - $str = curl_c($file,false); | 192 | + $str = curl_c($file, false); |
| 187 | foreach ($list as $item) { | 193 | foreach ($list as $item) { |
| 188 | $tmp = mb_convert_encoding($str, $item, $item); | 194 | $tmp = mb_convert_encoding($str, $item, $item); |
| 189 | if (md5($tmp) == md5($str)) { | 195 | if (md5($tmp) == md5($str)) { |
-
请 注册 或 登录 后发表评论