I have the need to run a PHP function that will generate a zip file, write to the database if it was generated and the date. And right after returning the warning that was generated.
At the moment I already have all created functions that do this. Only problem and how to do to call the function without the refresh on the page by button, update the text field with the generation date of the bank, if it was generated and the generation warning.
Below is the html part summarized to facilitate:
Arquivo gerado: <input type='text' readonly value=''>
Data de geração:<input type='text' readonly value=''>
Gerar arquivo:<input type="button" value="Gerar"/>
PHP:
class backup {
public function gera_arquivo() {
$zip = new ZipArchive();
if ( $zip->open( 'zips/arquivo.zip', ZipArchive::OVERWRITE ) === true) {
foreach( glob('Arquivos/DE/*.pdf') as $decreto )
$zip->addFile( $decreto, $decreto);
foreach( glob('Arquivos/PO/*.pdf') as $portaria )
$zip->addFile( $portaria, $portaria );
foreach( glob('Arquivos/LE/*.pdf') as $lei )
$zip->addFile( $lei, $lei );
foreach( glob('Arquivos/RE/*.pdf') as $resolucao )
$zip->addFile( $resolucao, $resolucao );
$zip->close();
}
I searched for hours on the internet, but I did not find anything that would give me a way, maybe the solution is for ajax, but I'm not very familiar with ajax.