1.服务器加个站点后,崩溃了 参见上上上篇文章
2.laravel-admin 我把一个服务器的一个站点复制到这个服务器的另一个站点之后(cs.your.com 到 015.your-com),无论怎么登录都不行,都提示用户名或密码错误。APP_url也改了,数据库也改了,甚至用同一个库都不行,然后复制好几次,密码重置了好几次,保证没啥问题,而且最后发现这个015 没有ssl证书,但是访问的时候 浏览器上是https,还带锁。
给这个015 申请ssl证书后,最后正确了
3.dcat 批量
控制器下加个这个
use App\Admin\Extensions\BatchDownload;
、、、
$grid->batchActions(new BatchDownload()); //批量下载二维码
、、、
batchaction类
<?php
namespace App\Admin\Extensions;
use App\Models\TmToilet;
use Dcat\Admin\Grid\BatchAction;
use ZipArchive;
class BatchDownload extends BatchAction
{
protected $title = '批量下载';
public function handle() {
$ids = $this->getKey(); //选中的id列表
foreach ($ids as $id) {
//一系列操作
}
}
}
<?php
namespace App\Admin\Extensions;
use App\Models\TmToilet;
use Dcat\Admin\Grid\BatchAction;
use ZipArchive;
class BatchDownload extends BatchAction
{
protected $title = '批量下载';
public function handle()
{
$ids = $this->getKey();
$zip = new ZipArchive();
$zipFileName = 'images_' . time() . '.zip';
$zipFilepath = storage_path('app/public/' . $zipFileName);
if ($zip->open($zipFilepath, ZipArchive::CREATE) === true) {
foreach ($ids as $id) {
// 假设您有一个方法来获取远程文件并保存到本地临时路径
$tempFilePath = $this->downloadQrCodeToTemp($id);
if ($tempFilePath && file_exists($tempFilePath)) {
$zip->addFile($tempFilePath, basename($tempFilePath));
}
}
$zip->close();
}
//$publicZipUrl = Storage::url($zipFileName);//多了一个admin
//$publicZipUrl = str_replace('/admin/', '/', $publicZipUrl);
$publicZipUrl = 'storage/'.$zipFileName; //还是多admin
//return $this->response()->download($publicZipUrl);//多了admin
//tm.cc/admin/storage/images_1724585381.zip
return $this->response()->download('../'.$publicZipUrl);
}
protected function downloadQrCodeToTemp($id)
{
// 从远程 URL 下载文件并保存到临时路径
$url = 'http://tm.cc/api/qrcode/' . $id;
$toilet_user =TmToilet::where('id', $id)->first();
$tempFilePath = storage_path('app/temp/' . $id . '_' .
$toilet_user->toiletname .'_'. $toilet_user->renovationtime .'_'.$toilet_user->fundsource .'_'.$toilet_user->renovationmode. '.png');
if (!file_exists(storage_path('app/temp'))) {
mkdir(storage_path('app/temp'));
}
if (!file_exists($tempFilePath)) {
file_put_contents($tempFilePath, file_get_contents($url));
}
if (!file_exists($tempFilePath)) {
return '系统错误';
}
// 使用 Guzzle 或 curl 下载文件到本地临时路径
copy($url, $tempFilePath);
return $tempFilePath;
}
}
//$publicZipUrl = Storage::url($zipFileName);//多了一个admin
//$publicZipUrl = str_replace('/admin/', '/', $publicZipUrl);
$publicZipUrl = 'storage/'.$zipFileName; //还是多admin
//return $this->response()->download($publicZipUrl);//多了admin
//tm.cc/admin/storage/images_1724585381.zip
return $this->response()->download('../'.$publicZipUrl);
这一块,这个download 应该是被dcat重载了?文件系统软链接也检查多了,是标准的,查看这个downloadn函数
public function download($url)
{
//return $this->then(['action' => 'download', 'value' => $url]); //20240825周日 添加
return $this->then(['action' => 'download', 'value' => admin_url($url)]);
}
修改掉admin_url 也不行 ,还是说项目的dcat的路径最好要放到admin下,期间出现试了好多函数,都不太行,要不报错,要不还是有admin
//$publicZipUrl = Storage::url($zipFileName);//多了一个admin
//$publicZipUrl = str_replace('/admin/', '/', $publicZipUrl);
$publicZipUrl = 'storage/'.$zipFileName;
//copy($zipFilepath, 'admin/'.$publicZipUrl);
//$publicZipUrl = storage_path('storage/' . $zipFileName);
// 下载 ZIP 文件
//return $this->response()->download($publicZipUrl);//这样的下载方式 会带一个admin,怎么修改
//return $this->response()->download($publicZipUrl);
//return Response::download("localhost\storage\images_1724578109.zip");
// return Response::download($publicZipUrl);
// return Storage::download($publicZipUrl);
//return $this->response()->download($publicZipUrl)->redirect('../storage/'.$zipFileName, '下载二维码');
return $this->response()->download('../'.$publicZipUrl);
//return $this->response()->redirect('localhost/storage/'.$zipFileName, '下载二维码');
return $this->response()->download(‘../’.$publicZipUrl);
指向上级目录,怎么一开始就没想到呢???!!!
4.乌班图2020版下配置宝塔出现问题
一开始宝塔下完,访问不了,如果是云服务器,要在面板加端口,只打命令不行。然后下载4件套出问题