How to make a download link in php?

How to make a download link in php?
Just redirect, I agree not long realtivity - but maybe there hotovoy script with schetchika and so on?
June 3rd 19 at 19:31
2 answers
June 3rd 19 at 19:33
Download link without PHP:
<a href="file.zip">download</a>

Download link with PHP:
<?php echo '<a href="file.zip"-->download ?>

Ask a question humanly.
June 3rd 19 at 19:35
Put the http header
Content-Disposition: attachment; filename=MyFileName.ext
And rejoice. Counter can inside this php file, just let receives from the database the number of downloads, adds one and saves back to the database. And then in a different place, you will be able to withdraw from the database, how many times have downloaded the file.
retrieves from the database the number of downloads, adds one and saves back to database

Don't forget to wrap this sequence in a transaction or to make a stored procedure.
Otherwise you can lose some units count with parallel user access. - jerrold_Hickle commented on June 3rd 19 at 19:38

Find more questions by tags PHP