To replace spaces with underscores and then remove everything that isn’t alpha-numeric open up
wolf/plugins/file_manager.FileManagerController.php
and replace the existing upload function (approx line 259) with this.
public function upload() {
$data = $_POST['upload'];
$path = str_replace('..', '', $data['path']);
$overwrite = isset($data['overwrite']) ? true: false;
if (isset($_FILES)) {
// $file = upload_file($_FILES['upload_file']['name'], FILES_DIR.'/'.$path.'/', $_FILES['upload_file']['tmp_name'], $overwrite);
$clean_file_name = preg_replace('/ /', '_', $_FILES['upload_file']['name'] );
$clean_file_name = preg_replace('/[^A-Za-z0-9_.]/', '', $clean_file_name );
$file = upload_file( $clean_file_name, FILES_DIR.'/'.$path.'/', $_FILES['upload_file']['tmp_name'], $overwrite);
if ($file === false)
Flash::set('error', __('File has not been uploaded!'));
}
redirect(get_url('plugin/file_manager/browse/'.$path));
}
Wolf CMS – Clean uploaded file names
Sep, 25 -- Categories: PHP