[Flask] Uploading image into MySQL Blob

Matt Shields matt at mattshields.org
Wed May 18 09:48:32 EDT 2016


I'm trying to get an image uploaded through a form and inserted into a Blob
field in MySQL.  This doesn't seem to work.  What's wrong?

clientid = request.form['clientid']
file = request.files['logo']
path = config.app_path()
filename = "%s-logo.png" % clientid
local_file = "%s/static/%s" % (path, filename)
file.save(local_file)
sql = "UPDATE client SET logo = LOAD_FILE('%s') WHERE clientid = '%s'" %
(local_file, clientid)
dbQuery(sql)   #This is custom function to run a sql query.

Matt
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/flask/attachments/20160518/e1f50c2f/attachment.html>


More information about the Flask mailing list