From: Roland Häder Date: Thu, 31 Mar 2016 09:11:02 +0000 (+0200) Subject: Append original (but secured) file name to random file name (optional). X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=94c77345c500fe036d91b27dc4c41482b942d194;p=simple-upload.git Append original (but secured) file name to random file name (optional). --- diff --git a/index.php b/index.php index 883405c..3971ac1 100644 --- 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, @@ -182,6 +185,8 @@ $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']));