Download script in php

I need to download .sql file in a folder. I have a button named download. And button has it’s own value.
ie.

(sql filename   action)
(1.sql   -------       download,
2.sql     --------     download)

when clicking on download button

Read More
if(isset($_REQUEST['download'])){echo $_REQUEST['download']; //result either 1.sql or 2.sql}
1.sql,2.sql are in the same folder in which my download.php file is placed.

This work is for my word press site.My need is to download 1.sql or 2.sql to my computer when corresponding button is clicked.

ie

if(isset($_REQUEST['download'])){download file.(ie.download $_REQUEST['download'])}.

Related posts

Leave a Reply

1 comment

  1. When you just want to download the file it’s this:

    header("Content-Type: application/octet-stream");
    header("Content-Disposition: attachment; filename="".$yourfilename.""");
    readfile($pathtoyourfile.$filename);