Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
What type of Data is in Blob?
Message
De
17/06/2007 08:36:13
 
 
À
16/06/2007 14:35:22
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
01233743
Message ID:
01233783
Vues:
16
>How to determine the data type stored in Blob. I mean whether the data stored in Blob is a Picture/Sound/.doc/.pdf or .xls.
>It can be possible to store the name of the file at the time of getting it (getfile()). Suppose there is no such information available.
>
>Thank you.

This function can easily be modified to handle more file types:
Function filetype
  Lparameters lcData
  Local lcReturn,lcContents
  If Pcount()=0 Or Vartype(lcData)#'C'
    lcReturn=''
  Else
    If Adir(laDummy,lcData)>0 && File
      lcContents=Filetostr(lcData)
    Else && Memory variabøe
      lcContents=lcData
    Endif
    Do Case
      Case Len(lcContents)<4
        lcReturn=''
      Case Left(lcContents,3)=Chr(0xFF)+Chr(0xD8)+Chr(0xFF)
        lcReturn='JPG'
      Case Left(lcContents,3)='GIF'
        lcReturn='GIF'
      Case Substr(lcContents,42,3)='EMF'
        lcReturn='EMF'
      Case Left(lcContents,4)=Chr(0xD7)+Chr(0xCD)+Chr(0xC6)+Chr(0x9A)
        lcReturn='WMF'
      Case Left(lcContents,4)=Chr(0x4D)+Chr(0x4D)+Chr(0x00)+Chr(0x2A)
        lcReturn='TIF'
      Case Left(lcContents,4)=Chr(0x89)+'PNG'
        lcReturn='PNG'
      Case Left(lcContents,2)='BM'
        lcReturn='BMP'
      Case Left(lcContents,3)='CWS' And Asc(Substr(lcContents,4,1))<16
        lcReturn='SWF'
      Case Left(lcContents,3)='FWS'  And Asc(Substr(lcContents,4,1))<16
        lcReturn='SWF'
      Otherwise
        lcReturn=''
    Endcase
  Endif
Return lcReturn
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform