小编use*_*123的帖子

TypeError: expected str, bytes or os.PathLike object, not FileStorage keeps popping up

def convertToBinaryData(filename):
    # Convert digital data to binary format
    with open(filename, 'rb') as file:
        binaryData = file.read()
    return binaryData
Run Code Online (Sandbox Code Playgroud)

This is my function for converting an image to binary...

uploaded_file = request.files['file']
if uploaded_file.filename != '':
    uploaded_file.save(uploaded_file.filename)
    empPicture = convertToBinaryData(uploaded_file)

Run Code Online (Sandbox Code Playgroud)

and this is the block of code where the uploaded file is received and saved, however, when it runs, I get this error...

    with open(filename, 'rb') as file:
TypeError: expected str, bytes or os.PathLike object, not FileStorage
Run Code Online (Sandbox Code Playgroud)

I'm pretty new …

python file-upload flask

5
推荐指数
1
解决办法
1万
查看次数

标签 统计

file-upload ×1

flask ×1

python ×1