Python: Check if uploaded file is jpg
问题 How can I check if a file uploaded by a user is a real jpg file in Python (Google App Engine)? This is how far I got by now: Script receives image via HTML Form Post and is processed by the following code ... incomming_image = self.request.get("img") image = db.Blob(incomming_image) ... I found mimetypes.guess_type, but it does not work for me. 回答1: If you need more than looking at extension, one way would be to read the JPEG header, and check that it matches valid data. The format for this