开发者

Blob extension validation

开发者 https://www.devze.com 2023-01-09 16:31 出处:网络
I use the following to insert a JPEG into a blob field: db.Blob(s开发者_如何学JAVAelf.request.get(\"imgFile\"))

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

精彩评论

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