CodeIgniter Forums
encrypt file upload - prompt user with original file name on download? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: encrypt file upload - prompt user with original file name on download? (/showthread.php?tid=16841)



encrypt file upload - prompt user with original file name on download? - El Forum - 03-17-2009

[eluser]Unknown[/eluser]
Let me start by saying that CI rocks! I've really enjoyed working with this well thought out framework.

I apologize if this has been posted before, but I was unable to find something relevant.

I'm using ['encrypt_name'] = TRUE; for a file upload.

I'm also storing the original file name in my database.

How can I prompt the user with the original file name when they try to download? I'd rather they not see the long, encrypted file name.

Thanks for any insight.


encrypt file upload - prompt user with original file name on download? - El Forum - 03-18-2009

[eluser]pistolPete[/eluser]
If your files are small use the download helper:
Code:
// get $data from db
$this->load->helper('download');
$file_data = file_get_contents('/path/to/'.$data['encrypted_filename']);
force_download($data['plain_filename'], $file_data);

If your files are too big to fit in memory, use one of the code examples from here:
Code:
(...)
header('Content-Disposition: attachment; filename="'.$data['plain_filename'].'"');
(...)