How to create download button in PHP [duplicate]

0

I have a download area where the file links are in a MYSQL table and I created a key that would be the key to download.

The table is this:

id|    arquivo |chave 
1 |arquivo.mp4 |e8d95a51f3af4a3b134bf6bb680a213a

The only way I can download it is with the link in href. The link comes from the mysql query.

foreach($results as $row){
 echo '<a href="/arquivos/'.$row->arquivo.'" download>Download</a>';
}

But I wanted to do it in a safer way, so that way the person can take the link and pass on to anyone. One possibility I thought of is to use the "key" column to download, for example click on download then it opens "?download=e8d95a51f3af4a3b134bf6bb680a213a" and I use $_GET to query it.

Is that the best way to create a secure download?

    
asked by anonymous 03.05.2018 / 23:46

0 answers