sanitize_filename($str[, $relative_path = FALSE])
Parameters: |
|
---|---|
Returns: |
Sanitized file name/path |
Return type: |
string |
Tries to sanitize filenames in order to prevent directory traversal attempts and other security threats, which is particularly useful for files that were supplied via user input.
1 | $filename = $this ->security->sanitize_filename( $this ->input->post( 'filename' )); |
If it is acceptable for the user input to include relative paths, e.g. file/in/some/approved/folder.txt, you can set the second optional parameter, $relative_path
to TRUE.
1 | $filename = $this ->security->sanitize_filename( $this ->input->post( 'filename' ), TRUE); |
Please login to continue.