1

I want to access images uploaded by the users to store it in the database.I have used request.files.get for the same. But it is returning a null string.Using just request.files is giving Immutable MultiDict Object error.

    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)})
Nisarg
  • 11
  • 2

0 Answers0