Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Detecting file type
Message
De
13/08/2005 14:42:54
 
 
À
13/08/2005 14:23:03
Information générale
Forum:
Visual FoxPro
Catégorie:
Photos et traitement d'images
Divers
Thread ID:
01040691
Message ID:
01040707
Vues:
14
>>Check the first few bytes of the file!
>>JPG starts with FF-D8-FF-00 (hex) or chr(255)+chr(216)+chr(255)+chr(0)
>>GIF starts with GIF (plain text)
>>PNG starts wiyh 89-50-E4-47 (hex) which is chr(37)+'PNG'
>
>This doesn't work.
>
>
>   * First, make sure this is a JPG
>   lcString=FILETOSTR(This.cSavePath)
>   IF SUBSTR(lcString,1,4)<>CHR(255)+CHR(216)+CHR(255)+CHR(0)
>      This.cHtml='This is not a JPG file.'
>      ERASE (This.cSavePath)
>      RETURN .F.
>   ENDIF
>
Ok, this small change did it:
   * First, make sure this is a JPG
   lcString=FILETOSTR(This.cSavePath)
   IF SUBSTR(lcString,1,2)<>CHR(0xFF)+CHR(0xD8)
      This.cHtml='This is not a JPG file.'
      ERASE (This.cSavePath)
      RETURN .F.
   ENDIF
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform