作者 lyh

gx

@@ -31,6 +31,7 @@ class ProjectKeywordController extends BaseController @@ -31,6 +31,7 @@ class ProjectKeywordController extends BaseController
31 $data['search_keywords'] = $info['search_keywords']; 31 $data['search_keywords'] = $info['search_keywords'];
32 $data['customer_keywords'] = $info['customer_keywords']; 32 $data['customer_keywords'] = $info['customer_keywords'];
33 $data['brand_keyword'] = $info['brand_keyword']; 33 $data['brand_keyword'] = $info['brand_keyword'];
  34 + $data['minor_keywords'] = $info['minor_keywords'];
34 $this->response('success',Code::SUCCESS,$data); 35 $this->response('success',Code::SUCCESS,$data);
35 } 36 }
36 37
@@ -119,7 +119,6 @@ class FileController @@ -119,7 +119,6 @@ class FileController
119 if($file_hash !== false){ 119 if($file_hash !== false){
120 return $this->response('资源',Code::SUCCESS,$this->responseData($file_hash['path'], $name)); 120 return $this->response('资源',Code::SUCCESS,$this->responseData($file_hash['path'], $name));
121 } 121 }
122 - $url = $this->config['root'].$this->path;  
123 $fileName = uniqid().rand(10000,99999).'.'.$files->getClientOriginalExtension(); 122 $fileName = uniqid().rand(10000,99999).'.'.$files->getClientOriginalExtension();
124 //同步数据到cos 123 //同步数据到cos
125 if($this->upload_location == 0){ 124 if($this->upload_location == 0){
@@ -130,12 +129,28 @@ class FileController @@ -130,12 +129,28 @@ class FileController
130 $amazonS3Service = new AmazonS3Service(); 129 $amazonS3Service = new AmazonS3Service();
131 $amazonS3Service->uploadFiles($files,$this->path,$fileName); 130 $amazonS3Service->uploadFiles($files,$this->path,$fileName);
132 } 131 }
  132 + $this->synchronizationFile($files->getClientOriginalExtension(),$fileName);
133 $this->saveMysql($fileModel,$files->getSize(),$files->getClientOriginalExtension(),$fileName,$hash,$this->upload_location,$files->getMimeType(),$name); 133 $this->saveMysql($fileModel,$files->getSize(),$files->getClientOriginalExtension(),$fileName,$hash,$this->upload_location,$files->getMimeType(),$name);
134 $this->response('资源',Code::SUCCESS,$this->responseData($this->path.'/'.$fileName, $name)); 134 $this->response('资源',Code::SUCCESS,$this->responseData($this->path.'/'.$fileName, $name));
135 } 135 }
136 136
137 - //curl -X POST -F "file=@/path/to/your/file.jpg" -F "save_link=/path/to/save/directory" https://www.example.com/upload.php  
138 - 137 + /**
  138 + * @remark :指定同步文件到獨立177服務器
  139 + * @name :synchronizationFile
  140 + * @author :lyh
  141 + * @method :post
  142 + * @time :2024/4/8 11:10
  143 + */
  144 + public function synchronizationFile($file_type,$fileName){
  145 + $fileTypeArr = ['zip', 'pdf', 'mp4', 'doc', 'docx', 'm4v', 'xlsx'];
  146 + if(in_array($file_type,$fileTypeArr)){
  147 + //同步到大文件
  148 + $file_path = getFileUrl($this->path.'/'.$fileName,$this->cache['storage_type'] ?? 0);
  149 + $cmd = 'curl -F "file_path='.$file_path.'" -F "save_path=/www/wwwroot/cos'.$this->path.'" https://v6-file.globalso.com/upload.php';
  150 + shell_exec($cmd);
  151 + }
  152 + return true;
  153 + }
139 154
140 /** 155 /**
141 * 接口上传单文件 156 * 接口上传单文件
1 -<?php  
2 -if(isset($_POST['file']) && isset($_POST['save_path'])) {  
3 - $savePath = $_POST['save_path'];  
4 - $fileUrl = $_POST['file'];  
5 - $targetDir = "uploads/";  
6 - $targetFile = $savePath . basename($fileUrl);  
7 - $fileContents = file_get_contents($fileUrl);  
8 - if(file_put_contents($targetFile, $fileContents)) {  
9 - echo "File saved successfully.";  
10 - } else {  
11 - echo "Error saving file.";  
12 - }  
13 -} else {  
14 - echo "Missing parameters.";  
15 -}  
16 -?>