I use the following to insert a JPEG into a blob field:
db.Blob(s开发者_如何学JAVAelf.request.get("imgFile"))
How can I check if "imgFile" is a JPEG?
I dont want to let people upload EXEs, etc.
Thank
Joel
The magic number for a JPEG file is FFD8 according to this site. What you could do is look at the two first bytes to see if they match before inserting the blob into the datastore.
精彩评论