我想使用CodeIgniter上传带有加密名称的文件。 但是,我尝试了两种可能性:
$config['file_name'] = md5($id);
或者:
$config['encrypt_name'] = TRUE;
两者都有效,但我的编目名称中有文件扩展名。上传文件时是否可以删除它? 当我看到上传系统库时,$ file-> ext在任何地方都使用..为什么要将文件扩展名放在加密名称中? 感谢。
答案 0 :(得分:0)
实际上有一种更简单的方法:
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
}
答案 1 :(得分:0)
打开system/libraries/Upload.php
从do_upload
功能
// 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);
}