stevesimo Posted November 14, 2008 Share Posted November 14, 2008 Hi, my client has asked me to generate a CSV file or Excel file which is straight forward enough to do. The complication is that they have asked if the file can be password protected. Does anyone know how I could achieve this. Is it actually possible to do this with PHP? Any advice on this subject would be appreciated. Steve Quote Link to comment Share on other sites More sharing options...
Mark Baker Posted November 14, 2008 Share Posted November 14, 2008 Hi, my client has asked me to generate a CSV file or Excel file which is straight forward enough to do. The complication is that they have asked if the file can be password protected. Does anyone know how I could achieve this. Is it actually possible to do this with PHP? About the only way to password protect a text file such as a CSV would be to zip it up in a password-protected zip. If you want to write the data to an Excel file, that can be password-protected. Quote Link to comment Share on other sites More sharing options...
DarkerAngel Posted November 14, 2008 Share Posted November 14, 2008 This can also be done with PHP, but I'm not going to write [all] the code for you. <?php /** User Check / Login Code / Password Check **/ if( file_exist($_GET['file']) ) { header('Content-Length: '.filesize($_GET['file']); header("Content-Disposition: attachment; filename=\"{$_GET['file']}\""); header('Content-type: application/vnd.ms-excel'); readfile($_GET['file']); } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.