正在显示
2 个修改的文件
包含
62 行增加
和
0 行删除
controller/Attachment.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace Controller; | ||
| 4 | + | ||
| 5 | + | ||
| 6 | +use Lib\Err; | ||
| 7 | +use Lib\Imap\ImapConfig; | ||
| 8 | +use Lib\Imap\ImapPool; | ||
| 9 | +use Lib\Mail\MailFun; | ||
| 10 | +use Model\folderSql; | ||
| 11 | +use Model\listsSql; | ||
| 12 | + | ||
| 13 | +/** | ||
| 14 | + * 附件预览 | ||
| 15 | + * @author:dc | ||
| 16 | + * @time 2025/8/19 17:43 | ||
| 17 | + * Class Attachment | ||
| 18 | + * @package Controller | ||
| 19 | + */ | ||
| 20 | +class Attachment extends Base { | ||
| 21 | + | ||
| 22 | + | ||
| 23 | + | ||
| 24 | + public function show(){ | ||
| 25 | + $path = app()->request('path'); | ||
| 26 | + $filename = ROOT_PATH.$path; | ||
| 27 | + if(file_exists($filename)){ | ||
| 28 | + $file = new \SplFileInfo($filename); | ||
| 29 | + if(in_array($file->getExtension(),['jpg','jpeg','png','gif','mp4','mp3','pdf','txt','doc','docx','xls','xlsx','ppt','pptx','eml'])){ | ||
| 30 | + header("Content-type: ".$file->getMTime()); | ||
| 31 | + header("Content-Disposition: inline; filename=".$file->getFilename()); | ||
| 32 | + header("Content-Length: ".$file->getSize()); | ||
| 33 | + header("Cache-Control: max-age=0"); | ||
| 34 | + header("Last-Modified: ".$file->getMTime()); | ||
| 35 | + header("Expires: " . gmdate("D, d M Y H:i:s", time() + 3600 * 24 * 365) . " GMT"); | ||
| 36 | + return file_get_contents($file->getPathname()) ; | ||
| 37 | + } | ||
| 38 | + return "<div style='text-align: center'>“".$file->getFilename()."“ 当前附件不支持预览</div>"; | ||
| 39 | + } | ||
| 40 | + return "<div style='text-align: center'>404 附件不存在</div>"; | ||
| 41 | + } | ||
| 42 | + | ||
| 43 | + | ||
| 44 | +} | ||
| 45 | + | ||
| 46 | + | ||
| 47 | + | ||
| 48 | + | ||
| 49 | + | ||
| 50 | + | ||
| 51 | + | ||
| 52 | + | ||
| 53 | + | ||
| 54 | + | ||
| 55 | + | ||
| 56 | + | ||
| 57 | + | ||
| 58 | + |
| @@ -88,6 +88,10 @@ return [ | @@ -88,6 +88,10 @@ return [ | ||
| 88 | // fob流程服务用到的搜索 | 88 | // fob流程服务用到的搜索 |
| 89 | ,'fob/ai/search' => [\Controller\fob_ai\MailListV2Es2::class,'search'] | 89 | ,'fob/ai/search' => [\Controller\fob_ai\MailListV2Es2::class,'search'] |
| 90 | 90 | ||
| 91 | + | ||
| 92 | + // 附件预览 | ||
| 93 | + ,'show.attachment.fob' => [\Controller\Attachment::class,'show'] | ||
| 94 | + | ||
| 91 | ]; | 95 | ]; |
| 92 | 96 | ||
| 93 | 97 |
-
请 注册 或 登录 后发表评论