- $data['target_file_name'] = '';
- while (strlen($data['target_file_name']) < $settings['random_name_len'])
- $data['target_file_name'] .= $settings['random_name_alphabet'][rand(0, strlen($settings['random_name_alphabet']) - 1)];
- if ($settings['random_name_keep_type'])
- $data['target_file_name'] .= '.' . pathinfo($data['uploaded_file_name'], PATHINFO_EXTENSION);
+ do {
+ $data['target_file_name'] = '';
+ while (strlen($data['target_file_name']) < $settings['random_name_len'])
+ $data['target_file_name'] .= $settings['random_name_alphabet'][rand(0, strlen($settings['random_name_alphabet']) - 1)];
+ if ($settings['random_name_keep_type'])
+ $data['target_file_name'] .= '.' . pathinfo($data['uploaded_file_name'], PATHINFO_EXTENSION);
+ } while (file_exists($data['target_file_name']))