![]() |
Is File Upload class creates unique file name when encrypt_name set true? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=11) +--- Thread: Is File Upload class creates unique file name when encrypt_name set true? (/showthread.php?tid=72048) |
Is File Upload class creates unique file name when encrypt_name set true? - karthik_code - 10-29-2018 Is File Uploading class in code ignter creates unique file name when encrypt_name set true? PHP Code: $config['upload_path'] = $abs_path; RE: Is File Upload class creates unique file name when encrypt_name set true? - InsiteFX - 10-30-2018 It's in the User's Guide. encrypt_name If set to TRUE the file name will be converted to a random encrypted string. This can be useful if you would like the file saved with a name that can not be discerned by the person uploading it. RE: Is File Upload class creates unique file name when encrypt_name set true? - karthik_code - 10-30-2018 (10-30-2018, 03:07 AM)InsiteFX Wrote: It's in the User's Guide.Thanks for the quick reply. I already read the guide. My question is, whether it will be a unique name. Because, I am storing all user uploads in a single folder, hence it should not be overwritten at any time. Also, I could not able to find a way to prefix a unique id to the random filename. If I manually set a unique file name, unable to determine the original file's extension. RE: Is File Upload class creates unique file name when encrypt_name set true? - dave friend - 10-30-2018 encrypt_name does not guarantee a unique file name. That said, the chance of a name collision is incredibly small. But a small chance is not the same as no chance. You might be interested to know that do_upload() calls set_filename() and set_filename() will append a number to the end of the filename to avoid overwriting a pre-existing file. This happens for any file upload encrypted name or not. RE: Is File Upload class creates unique file name when encrypt_name set true? - jreklund - 10-30-2018 Personally I'm using a UUID version 4 generator for my file names and all ID (instead of auto increment). PHP Code: if ( ! function_exists('UUIDv4')) https://en.wikipedia.org/wiki/Universally_unique_identifier#Collisions RE: Is File Upload class creates unique file name when encrypt_name set true? - karthik_code - 10-31-2018 (10-30-2018, 09:41 AM)dave friend Wrote: You might be interested to know that do_upload() calls set_filename() and set_filename() will append a number to the end of the filename to avoid overwriting a pre-existing file. This happens for any file upload encrypted name or not.This is the function i want. RE: Is File Upload class creates unique file name when encrypt_name set true? - karthik_code - 10-31-2018 Thanks @jreklund & @Dave friend, I finally ended with prefixing auto-increament id along with uuid to the uploaded file name. I worried about setting the original file's extension with filename, but CodeIgniter automatically preserves the original file's extension even I didn't mention it in $config['file_name'] parameter. RE: Is File Upload class creates unique file name when encrypt_name set true? - Gurutechnolabs - 11-02-2018 You need a .htaccess file on your root folder like below code RewriteEngine On RewriteCond %{REQUEST_URI} ^/system.* RewriteRule ^(.*)$ index.php?/$1 [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.+)$ index.php?/$1 [L] |