upload max filename less than 32 does not work |
I'm trying to set up the upload library configuration as follows:
PHP Code: $attachmentEXT = array('doc', 'docx', 'jpg', 'jpeg', 'pdf', 'png', 'rar', 'zip'); 27 characters for encrypted file name 5 characters for the file extension. But I get when uploading DOCX, file name length is 37. 32 characters for encrypted file name 5 characters for the file extension. What's wrong with the above configuration?
I believe that 'max_filename' only pertains to the name of the selected file and has nothing to do with the encrypted name. Perhaps it should, but it does not.
(01-30-2018, 04:27 PM)daveĀ friend Wrote: I believe that 'max_filename' only pertains to the name of the selected file and has nothing to do with the encrypted name. Perhaps it should, but it does not. For now I assume that `max_filename` only calculates file names excluding extensions. Then there I set `max_filename` with 27 characters and the length of the extension is 5. so the total length is 32 characters. But the fact that I get 32 characters for the length of file name & length of extension is 5.
`max_filename` length includes the extension and the (dot).
The class method that limits the file name length is cleverly called limit_filename_length(). It accepts two arguments $filename, $length and returns a string. When I run this code PHP Code: $this->load->library('upload'); The output is Code: some long.asdfg Which is exactly 15 characters including the dot. The code that runs if 'encrypt_name' === TRUE doesn't happen until after limit_filename_length() is called.The encrypt name value is derived from md5(uniqid(mt_rand())) . md5() returns a 32-character hexadecimal number. So the file name length is for sure more than the 15 characters we specified earlier. It's going to be exactly 32 characters plus the length of the file extension and the dot - so a length of 38 with our ".asdfg" type file. The moral of the story is that if you use 'encrypt_name' => TRUE then 'max_filename' has no effect. (01-31-2018, 02:41 AM)daveĀ friend Wrote: `max_filename` length includes the extension and the (dot). Thanks for the explanation, I think when `encrypt_name` is given TRUE then` max_filename` will work Perhaps the documentation section needs to be updated as described above, so that a layman like me is easy to understand ![]() |
Welcome Guest, Not a member yet? Register Sign In |