-
-
Save scriptdev/4e783fb69ae95f268b1046f618bce5c7 to your computer and use it in GitHub Desktop.
LINK DOWNLOAD DO ARQUIVO NO DATAGRID
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
COMPONENTE : TFile | |
TIPO DE GRAVAÇÃO : Armazenar o conteúdo e nome do arquivo na tabela | |
COLUNA PARA ARMAZENAR OS DADOS : campo: base64_dados | |
COLUNA PARA ARMAZENAR O NOME DO ARQUIVO : campo: nome_arquivo | |
*/ | |
$column_conteudo_arquivo_transformed->setTransformer(function($value, $object, $row) | |
{ | |
$action = new TAction(['DocumentoList', 'baixarDocumento'], ['key' => $object->id]); | |
$a = new TElement('a'); | |
$a->class = 'btn btn-link'; | |
$a->generator = 'adianti'; | |
$a->href = $action->serialize(); | |
$a->add($object->nome_arquivo); | |
return $a; | |
}); | |
# MÉTODO DO FORMULÁRIO | |
public static function baixarDocumento($param = []) | |
{ | |
try | |
{ | |
TTransaction::open(self::$database); | |
$anexosCliente = new AnexosCliente($param['key']); | |
$caminho_arquivo = "tmp/{$anexosCliente->nome_arquivo}"; | |
if(!is_file($caminho_arquivo)) | |
{ | |
file_put_contents($caminho_arquivo, base64_decode($anexosCliente->conteudo_arquivo)); | |
} | |
TTransaction::close(); | |
TPage::openFile($caminho_arquivo); | |
} | |
catch (Exception $e) | |
{ | |
new TMessage('error', $e->getMessage()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment