Eduardo Fuerte
asked on
How to make a button to start a configured file download in PHP?
Hi Experts!
I'm facing difficulties to make a form with a button to fire a download.
This form must send a parametrized name of a file to be downloaded.
The download_pdf_publicacoes.p hp
Thanks in advance!
I'm facing difficulties to make a form with a button to fire a download.
This form must send a parametrized name of a file to be downloaded.
....
<tr>
<td class="tg-yw4l">
<!-- The point where I intend to fire the download -->
<form action="download_pdf_publicacoes.php" method="post">
// This is the file to be downloaded:
<?php "base_url("."cesanshome/carregando_arquivo/".$idpublicacoes.")" ?>
// Here: How to configure it to send to the other page?
<input type="submit" name="download_pdf" value="PDF"/>
</form>
</td>
</tr>
...
The download_pdf_publicacoes.p
<?php
// How the $filename name must be received here?
$post = filter_input(INPUT_POST,"download_pdf");
if ($post)
{
$filename = ???;
header("Content-Type: application/octet-stream");
header("Content-Length: " . filesize($filename));
header("Content-Disposition: attachment; filename=" . basename($filename));
readfile($filename);
}
?>
Thanks in advance!
ASKER
Hello
Could you give me just one more help?
Using your function in a button.
This piece of code doesn't work out, what's wrong and what coudl be done to fix it?
To make it more difficult this Project uses CodeIgniter... so the localization is much more complex.
Could you give me just one more help?
Using your function in a button.
This piece of code doesn't work out, what's wrong and what coudl be done to fix it?
<form action="force_download(<?php echo base_url("cesanshome/carregando_arquivo/$idpublicacoes)"); ?>" method="post">
<input type="submit" value="PDF"/>
</form>
To make it more difficult this Project uses CodeIgniter... so the localization is much more complex.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you very much for the assistance, Ray!
Glad to help! Best of luck with the project, ~Ray
Open in new window