[英]special character in file name is missing while using http post to upload a file onto server running python flask
example file name: 2^8.txt
示例文件名:
2^8.txt
my request:我的请求:
var fileSelect = document.getElementById('myfile');
var files = fileSelect.files;
var formData = new FormData();
var file = files[0];
formData.append('file', file, file.name);
How i printed the file name using python flask:我如何使用 python flask 打印文件名:
if request.method == 'POST':
if 'file' not in request.files:
flash('No file part')
return jsonify(status="fail")
file = request.files['file']
filename = secure_filename(file.filename)
print(filename)
I got 28.txt
instead of 2^8.txt
我得到
28.txt
而不是2^8.txt
I have tried using encodeURI(), but it didn't work.我曾尝试使用 encodeURI(),但它没有用。
The "^" character is being removed by the secure_filename(file.filename)
function call, because werkzeug deems it unsafe (I'm not sure why but there will be a reason.). secure_filename(file.filename)
function 调用正在删除“^”字符,因为 werkzeug 认为它不安全(我不知道为什么,但会有一个原因。)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.