...
|
...
|
@@ -495,7 +495,6 @@ class AdminCommonController extends AdminBaseController |
|
|
mkdir($files_url);
|
|
|
}
|
|
|
$file_url = ROOT_PATH . '/public/upload/export/'.$file_name;
|
|
|
// chmod(ROOT_PATH . '/public/upload/export/', 0777);
|
|
|
$writer->save($file_url);
|
|
|
//相对路径
|
|
|
$url = 'upload/export/'.$file_name;
|
...
|
...
|
@@ -584,7 +583,10 @@ class AdminCommonController extends AdminBaseController |
|
|
}
|
|
|
$zip->close();//关闭
|
|
|
|
|
|
chmod($zipName, 0777);//适用于linux
|
|
|
$sys = $this->getOperateSys();
|
|
|
if($sys == 'Linux'){
|
|
|
chmod($zipName, 0777);//适用于linux
|
|
|
}
|
|
|
|
|
|
// if(!file_exists($zipName)){
|
|
|
// exit("无法找到文件"); //即使创建,仍有可能失败
|
...
|
...
|
@@ -592,8 +594,10 @@ class AdminCommonController extends AdminBaseController |
|
|
|
|
|
//如果不要下载,下面这段删掉即可,如需返回压缩包下载链接,只需 return $zipName;
|
|
|
|
|
|
//中文导出需要转码
|
|
|
// $zipName=iconv('UTF-8','GB2312',$zipName);
|
|
|
if($sys == 'Windows'){
|
|
|
//中文导出需要转码
|
|
|
$zipName=iconv('UTF-8','GB2312',$zipName);
|
|
|
}
|
|
|
|
|
|
header("Cache-Control: public");//任何情况下都可以得到资源参考:https://blog.csdn.net/u012375924/article/details/82806617
|
|
|
header("Content-Description: File Transfer");
|
...
|
...
|
@@ -817,4 +821,18 @@ class AdminCommonController extends AdminBaseController |
|
|
die(json_encode($result,JSON_UNESCAPED_UNICODE));
|
|
|
}
|
|
|
|
|
|
//判断当前操作系统
|
|
|
public function getOperateSys(){
|
|
|
$os_name = PHP_OS;
|
|
|
//判断
|
|
|
if(strpos($os_name,"Linux")!==false){
|
|
|
$os_str="Linux";
|
|
|
}else if(strpos($os_name,"Windows")!==false){
|
|
|
$os_str="Windows";
|
|
|
}else{
|
|
|
$os_str='';
|
|
|
}
|
|
|
return $os_str;
|
|
|
}
|
|
|
|
|
|
} |
...
|
...
|
|