custom file download wordpress admin plugin

I want to add functionality to the wordpress plugin to download custom file.
here is my code.

add_action('admin_menu','function_name');

and here is the download code.

Read More
header("Content-Disposition: attachment; filename=map.html");
header("Content-Length: ".strlen($content));
echo $content;
exit;

But, I’m getting error.

[22-Feb-2015 00:00:00 UTC] PHP Warning:  Cannot modify header information - headers already sent by (output started at /path/to/wp/wp-admin/includes/template.php:1877) in /path/to/wp/wp-content/plugins/plugin-name/lib/model.php on line 99

I’m making the request like this

http://www.website.com/wp-admin/admin.php?page=file-download&fileid=10

Related posts

Leave a Reply

1 comment