[eluser]xwero[/eluser]
You can set the config option encrypt_name to true and then replace the encrypted file name with your file name
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);
if ( ! $this->upload->do_upload())
{
$error = array('error' => $this->upload->display_errors());
$this->load->view('upload_form', $error);
}
else
{
$data = $this->upload->data();
rename($data['full_path'],$data['file_path'].$_POST['filename'].$data['file_ext']);
}
You should validate your filename if it is posted of course but this is the code that comes closest to renaming a file before uploading.
Using native php functions you just rename the tempfile that is uploaded.