I use attachment for upload file excel. I use PHPExcel for read that file and store to database like record by line. I saw file uploaded in data/upload folder ( default folder upload ). That file's name like base64 ( 62fdf2008fadc0939 ). I want to get Uri of that file like " data/upload/acb.xls ". How I get it ? Thank u so much.
Upload file Excel and read it.
Collapse
X
-
If you want to get local file path (not publicly accessible URL) you can use `getFilePath` method of Attachment repository. Here's an example:
PHP Code:use Espo\Entities\Attachment; // ... /** @var Attachment|null $attachment */ $attachment = $this->entityManager->getEntity(Attachment::ENTITY_TYPE, $id); // ... do stuff. e.g. check that attachment exists, check read permissions etc. $filePath =$this->entityManager->getRepository(Attachment::ENTITY_TYPE)->getFilePath($attachment); $spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($filePath); // ...
Last edited by mozkomor; 08-26-2022, 09:38 AM.Comment
Comment