I need to create a TXT file for the user, but I don't want to simply store it the server because it's sensitive information, and it seems like someone could just type www.server.com/filename.TXT and steal this sensitive information.
Is it possible to create a TXT file for a user to download without ever storing it on the server? Any other ideas?
Download File Securely
Moderator: General Moderators
Re: Download File Securely
Several options:
1 - generate the data on-the-fly whenever the user requests it
2 - encrypt the data so that downloading is only possible with the right credentials
And regardless of this, make sure you're using SSL (https) otherwise anyone will be able to sniff the data, no matter how well you protect it server-side.
1 - generate the data on-the-fly whenever the user requests it
2 - encrypt the data so that downloading is only possible with the right credentials
And regardless of this, make sure you're using SSL (https) otherwise anyone will be able to sniff the data, no matter how well you protect it server-side.
-
Number1SuperGuy
- Forum Newbie
- Posts: 10
- Joined: Thu Jun 17, 2010 11:21 am
Re: Download File Securely
Definitely getting SSL
I'm able to generate this data on-the-fly, in fact that's preferred, how can I let the user save this data as a text file without storing it on the server first?
Re: Download File Securely
Code: Select all
<?php
$s = "Generate file contents here";
$s .= "\n bla \n bla \n bla...";
header('Pragma: public');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Content-Type: text/plain; charset=utf-8');
header('Content-Length: '.strlen($s));
header('Content-Disposition: attachment; filename="TopSecret.txt"');
die($s);
?>