开发者

Blob extension validation

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜