]> git.mxchange.org Git - simple-upload.git/commitdiff
Append original (but secured) file name to random file name (optional).
authorRoland Häder <roland@mxchange.org>
Thu, 31 Mar 2016 09:11:02 +0000 (11:11 +0200)
committerRoland Häder <roland@mxchange.org>
Thu, 31 Mar 2016 09:11:02 +0000 (11:11 +0200)
index.php

index 883405c9a6da38d97e69066d9ed517e2787fe01a..3971ac17942fd3d1ef2bc7d8ced3d5569c5d1faf 100644 (file)
--- a/index.php
+++ b/index.php
@@ -56,6 +56,9 @@
                // Random file name letters
                'random_name_alphabet' => 'qazwsxedcrfvtgbyhnujmikolp1234567890',
 
+               // Add original name (but cleaned) to file name if random file name feature is enabled?
+               'suffix_original_name' => false,
+
                // Display debugging information
                'debug' => false,
 
                                $file_data['target_file_name'] = '';
                                while (strlen($file_data['target_file_name']) < $settings['random_name_len'])
                                        $file_data['target_file_name'] .= $settings['random_name_alphabet'][mt_rand(0, strlen($settings['random_name_alphabet']) - 1)];
+                               if ($settings['suffix_original_name'])
+                                       $file_data['target_file_name'] .= '_' . preg_replace('/[^0-9a-zA-Z_-]/', '', pathinfo($file_data['uploaded_file_name'], PATHINFO_BASENAME));
                                if ($settings['random_name_keep_type'])
                                        $file_data['target_file_name'] .= '.' . pathinfo($file_data['uploaded_file_name'], PATHINFO_EXTENSION);
                        } while (isReadableFile($file_data['target_file_name']));