作者 lyh

gx

... ... @@ -31,6 +31,7 @@ class ProjectKeywordController extends BaseController
$data['search_keywords'] = $info['search_keywords'];
$data['customer_keywords'] = $info['customer_keywords'];
$data['brand_keyword'] = $info['brand_keyword'];
$data['minor_keywords'] = $info['minor_keywords'];
$this->response('success',Code::SUCCESS,$data);
}
... ...
... ... @@ -119,7 +119,6 @@ class FileController
if($file_hash !== false){
return $this->response('资源',Code::SUCCESS,$this->responseData($file_hash['path'], $name));
}
$url = $this->config['root'].$this->path;
$fileName = uniqid().rand(10000,99999).'.'.$files->getClientOriginalExtension();
//同步数据到cos
if($this->upload_location == 0){
... ... @@ -130,12 +129,28 @@ class FileController
$amazonS3Service = new AmazonS3Service();
$amazonS3Service->uploadFiles($files,$this->path,$fileName);
}
$this->synchronizationFile($files->getClientOriginalExtension(),$fileName);
$this->saveMysql($fileModel,$files->getSize(),$files->getClientOriginalExtension(),$fileName,$hash,$this->upload_location,$files->getMimeType(),$name);
$this->response('资源',Code::SUCCESS,$this->responseData($this->path.'/'.$fileName, $name));
}
//curl -X POST -F "file=@/path/to/your/file.jpg" -F "save_link=/path/to/save/directory" https://www.example.com/upload.php
/**
* @remark :指定同步文件到獨立177服務器
* @name :synchronizationFile
* @author :lyh
* @method :post
* @time :2024/4/8 11:10
*/
public function synchronizationFile($file_type,$fileName){
$fileTypeArr = ['zip', 'pdf', 'mp4', 'doc', 'docx', 'm4v', 'xlsx'];
if(in_array($file_type,$fileTypeArr)){
//同步到大文件
$file_path = getFileUrl($this->path.'/'.$fileName,$this->cache['storage_type'] ?? 0);
$cmd = 'curl -F "file_path='.$file_path.'" -F "save_path=/www/wwwroot/cos'.$this->path.'" https://v6-file.globalso.com/upload.php';
shell_exec($cmd);
}
return true;
}
/**
* 接口上传单文件
... ...
<?php
if(isset($_POST['file']) && isset($_POST['save_path'])) {
$savePath = $_POST['save_path'];
$fileUrl = $_POST['file'];
$targetDir = "uploads/";
$targetFile = $savePath . basename($fileUrl);
$fileContents = file_get_contents($fileUrl);
if(file_put_contents($targetFile, $fileContents)) {
echo "File saved successfully.";
} else {
echo "Error saving file.";
}
} else {
echo "Missing parameters.";
}
?>