I want to upload my files with an encrypted name with CodeIgniter. But, I try the 2 possibilities :
$config['file_name'] = md5($id);
Or :
$config['encrypt_name'] = TRUE;
Both works, but I have the file extension in my encripted name. Is it possible to remove it when uploading my file ? When I see the Upload system library, the $file->ext is used everywhere.. Why put the file extension in an encrypted name ? Thanks.
There really is a much easier way of doing this:
if ($this->upload->do_upload()) // If file was uploaded
{
$data = $this->upload->data(); // Returns information about your uploaded file.
$new_name=md5($id);
$thumbnail = $new_name.$data['file_ext']; // Here it is
}
Open system/libraries/Upload.php
Remove or Comment out this code from do_upload
function
// If no extension was provided in the file_name config item, use the uploaded one
if (strpos($this->_file_name_override, '.') === FALSE)
{
$this->file_name .= $this->file_ext;
}
else
{
// An extension was provided, let's have it!
$this->file_ext = $this->get_extension($this->_file_name_override);
}