我想访问用户上传的图像以将其存储在数据库中。我也使用了 request.files.get 。但它返回一个空字符串。仅使用 request.files 会给出 Immutable MultiDict Object 错误。
def vehicleRegistration():
try :
_worthiness = request.files.get('worthinessCertificate','')
_insurance = request.files.get('insuranceCertificate','')
conn = mysql.connect()
cursor = conn.cursor()
cursor.callproc('sp_vehicleRegistration',(_worthiness,_insurance))
data = cursor.fetchall()
if len(data) is 0:
conn.commit()
return jsonify(data=data)
else:
return json.dumps({'error':str(data[0])})
cursor.close()
conn.close()
except Exception as e:
return json.dumps({'error':str(e)})