views:

26

answers:

1

Hey!

I use the following to insert a JPEG into a blob field:

db.Blob(self.request.get("imgFile"))

How can I check if "imgFile" is a JPEG?

I dont want to let people upload EXEs, etc.

Thank

Joel

A: 

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.

Gab Royer