Skip to content
Advertisement

Downloading a file from a PHP server via a website [closed]

I have physical files which I want users to download on my website. The files are located at:

C:/xampp/htdocs/myfile/uploads/*

I need a PHP script which can download files dynamically on click. Let’s say I have the following button which when clicked it triggers magic.php script.

<a href="magic.php?file=name"> Download file </a>

What PHP code do I need in magic.php to download the file name I passed in the query parameters?

Advertisement

Answer

Download link

JavaScript

magic.php page

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement