mysqldump and download

[size="3"]Hi comunnity.

My yii2 app has an option to make a back up of the database.

I do that with mysqldump in a specific folder that the user chooses in configuration.

How do I get the db.sql automatically downloaded to the download folder (linux or windows) like PhpMyAdmin does in the export option?

Thank you.