read file from form input type filepython 1

read file from form input type filepython

>>> secure_filename('../../../../home/username/.bashrc')
'home_username_.bashrc'

Here is what the above code is Doing:
1. The function secure_filename() takes a filename and makes it safe,
that means that it can’t contain any directory traversal attacks.
2. The function os.path.join() is used to join the filename to the path.
3. The function os.path.abspath() is used to get the absolute path of the file.
4. The function os.path.normpath() is used to normalize the path.
5. The function os.path.basename() is used to get the base name of the file.
6. The function werkzeug.secure_filename() is used to secure the filename.

Similar Posts