Welcome Guest, Not a member yet? Register   Sign In
Extend File Upload to utilize mcrypt
#1

[eluser]dionysus[/eluser]
Is there a way to enable/modify the file upload class to utilize mcrypt to encrypt files that are being uploaded to the system? Not just the filename, but the file itself?

thanks!
#2

[eluser]steelaz[/eluser]
You can extend base Upload class to add this function, CodeIgniter has class for encrypting data (defaults to mcrypt) - http://ellislab.com/codeigniter/user-gui...ption.html
#3

[eluser]dionysus[/eluser]
I decided to forgo modifying the upload class. What I did was after the file was uploaded, open the file, encrypt it, and write it out again.

Code:
$f=file_get_contents(BASE_PATH.$fileFullPath) or die ('no gfc');
$encf=$this->encrypt->encode($f,$this->e_key) or die ('no encrypt');
$nf=fopen(BASE_PATH.$fileFullPath,"r+") or die ('no open ');
$fw=fwrite($nf,$encf) or die ('no fwrite');
fclose($nf);
#4

[eluser]steelaz[/eluser]
That works too. Also, when you upload a file using CodeIgniter's File Upload class, instead of file_get_contents(BASE_PATH.$fileFullPath), you can do this:

Code:
$file_data = $this->upload->data();
$file_contents = file_get_contents($file_data['full_path']);




Theme © iAndrew 2016 - Forum software by © MyBB