CodeIgniter Forums
It's possible get the encrypted value using Upload class? - 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: It's possible get the encrypted value using Upload class? (/showthread.php?tid=2011)



It's possible get the encrypted value using Upload class? - El Forum - 07-11-2007

[eluser]Unknown[/eluser]
Hi every:
I'm building a application and need some upload stuff. For this I use CI Upload Class but I have some questions about it. First take a look to this code:
Code:
$upload['encrypt_name'] = true;
$this->load->library('upload', $upload);
This generate a encrypted name for uploaded file as doc said. My problem is that with $this->upload->data() can't get this encrypted name for inserted after in the DB. Any knows if this is possible or how to solve this problem?
Cheers


It's possible get the encrypted value using Upload class? - El Forum - 03-22-2008

[eluser]oliviermarian[/eluser]
Late reply, but may help someone else (I was looking fo this answer and found this post).

my working code:

Code:
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size']    = '100';
$config['max_width']  = '1024';
$config['max_height']  = '768';
$config['encrypt_name']  = TRUE;
$this->load->library('upload', $config);

//try upload
if ( ! $this->upload->do_upload())
{
    // error
    $this->load->view('upload_form', $error);
}    
// HERE IS THE POINT
$uploaded_data = $this->upload->data();
$file = $uploaded_data['file_name'];

hope this helps
Olivier.