Re: how to determine the actual file format of an image file?

This WebDNA talk-list message is from

2002


It keeps the original formatting.
numero = 44562
interpreted = N
texte = Rob,Thanks for the info, I was actually starting to go that route but then did some testing by uploading for example a bmp file that had a file extension of .jpg and the browser told me it was a .jpg file instead of .bmp which is what the file really was.This is based on the field (using formvariables) which contains Content-Type:--- Content-Disposition: form-data; name=profilePic; filename=clipart_bmp3.gif Content-Type: image/gif ---The image is really a bmp file with a .gif file extension. I did this test due to having received many files from my users in the past which had incorrect file extensions. Also some of my users send pics with no file extension at all.I was wondering about being able to do something like: [GetChars start=1&end=20][filename][/GetChars]To hopefully find some standard header string within the file format.DaleOn Wednesday, October 30, 2002, at 06:35 PM, Rob Marquardt wrote:> on 10/30/02 11:22 AM, dale's stuff at stuff@colony.net so noted... > >> does anyone know how to determine the actual file format of an image file >> that has been uploaded? >> >> I do not wish to rely just on the file extension as supplied by the user. > > I ignore the extension and look at the MIME type as supplied by the browser > during the processing of the upload. > > > [text]ca_fileType=[middle startafter=Content-Type: ][name][/middle][/text] > > [if ([ca_fileType]^/gif)][then] > [text]ca_fileExt=gif[/text][/then] > [else] > > [if ([ca_fileType]^/jpeg)][then] > [text]ca_fileExt=jpeg[/text][/then] > [else] > > [if ([ca_fileType]^/msword)][then] > [text]ca_fileExt=doc[/text][/then] > [else] > > [if ([ca_fileType]^/plain)|([ca_fileType]^/x-usenet-faq)][then] > [text]ca_fileExt=txt[/text][/then] > [else] > > [if > ([ca_fileType]^/rtf)|([ca_fileType]^/x- > rtf)|([ca_fileType]^/richt > ext)][then] > [text]ca_fileExt=rtf[/text][/then] > [else] > > [if > ([ca_fileType]^/mspowerpoint)|([ca_fileType]^/powerpoint)|( > [ca_file > Type]^/vnd.ms-powerpoint)|([ca_fileType]^/x-mspowerpoint)][then] > [text]ca_fileExt=ppt[/text][/then] > [else] > > [if ([ca_fileType]^/pdf)][then] > [text]ca_fileExt=pdf[/text][/then] > [else] > > [if > ([ca_fileType]^/x- > compressed)|([ca_fileType]^/x-zip-compressed)|([c > a_fileType]^/zip)|([ca_fileType]^/x-zip)][then] > [text]ca_fileExt=zip[/text][/then] > [else] > > [if ([ca_fileType]^/x-sit)|([ca_fileType]^/x-stuffit)][then] > [text]ca_fileExt=sit[/text][/then] > [else] > > [text > multi=T]ca_linkedError=T&ca_localErr=T&ca_linkedError.[ca_linkedNum]=Linked > file is not a supported type[/text] > > [/else][/if][/else][/if][/else][/if][/else][/if][/else][/if][/else][/if] > [/else][/if][/else][/if][/else][/if] > > > Rob Marquardt > Designer/Resident Wirehead > Toast Design > > 800 Washington Avenue North > Minneapolis MN 55401 > 612.330.9863 v > 612.321.9424 f > www.toastdesign.com ------------------------------------------------------------- This message is sent to you because you are subscribed to the mailing list . To unsubscribe, E-mail to: To switch to the DIGEST mode, E-mail to Web Archive of this list is at: http://search.smithmicro.com/ Associated Messages, from the most recent to the oldest:

    
  1. Re: how to determine the actual file format of an image file? (Rob Marquardt 2002)
  2. Re: how to determine the actual file format of an image file?- done (dale's stuff 2002)
  3. Re: how to determine the actual file format of an image file? (dale's stuff 2002)
  4. Re: how to determine the actual file format of an image file? (Jason Tyler 2002)
  5. Re: how to determine the actual file format of an image file? (dale's stuff 2002)
  6. Re: how to determine the actual file format of an image file? (Rob Marquardt 2002)
  7. Re: how to determine the actual file format of an image file? (Glenn Busbin 2002)
  8. Re: how to determine the actual file format of an image file? (Frank Nordberg 2002)
  9. Re: how to determine the actual file format of an image file? (Brian Boegershausen 2002)
  10. Re: how to determine the actual file format of an image file? (Alain Russell 2002)
  11. Re: how to determine the actual file format of an image file? (dale's stuff 2002)
  12. Re: how to determine the actual file format of an image file? (Rob Marquardt 2002)
  13. how to determine the actual file format of an image file? (dale's stuff 2002)
Rob,Thanks for the info, I was actually starting to go that route but then did some testing by uploading for example a bmp file that had a file extension of .jpg and the browser told me it was a .jpg file instead of .bmp which is what the file really was.This is based on the field (using formvariables) which contains Content-Type:--- Content-Disposition: form-data; name=profilePic; filename=clipart_bmp3.gif Content-Type: image/gif ---The image is really a bmp file with a .gif file extension. I did this test due to having received many files from my users in the past which had incorrect file extensions. Also some of my users send pics with no file extension at all.I was wondering about being able to do something like: [GetChars start=1&end=20][filename][/GetChars]To hopefully find some standard header string within the file format.DaleOn Wednesday, October 30, 2002, at 06:35 PM, Rob Marquardt wrote:> on 10/30/02 11:22 AM, dale's stuff at stuff@colony.net so noted... > >> does anyone know how to determine the actual file format of an image file >> that has been uploaded? >> >> I do not wish to rely just on the file extension as supplied by the user. > > I ignore the extension and look at the MIME type as supplied by the browser > during the processing of the upload. > > > [text]ca_fileType=[middle startafter=Content-Type: ][name][/middle][/text] > > [if ([ca_fileType]^/gif)][then] > [text]ca_fileExt=gif[/text][/then] > [else] > > [if ([ca_fileType]^/jpeg)][then] > [text]ca_fileExt=jpeg[/text][/then] > [else] > > [if ([ca_fileType]^/msword)][then] > [text]ca_fileExt=doc[/text][/then] > [else] > > [if ([ca_fileType]^/plain)|([ca_fileType]^/x-usenet-faq)][then] > [text]ca_fileExt=txt[/text][/then] > [else] > > [if > ([ca_fileType]^/rtf)|([ca_fileType]^/x- > rtf)|([ca_fileType]^/richt > ext)][then] > [text]ca_fileExt=rtf[/text][/then] > [else] > > [if > ([ca_fileType]^/mspowerpoint)|([ca_fileType]^/powerpoint)|( > [ca_file > Type]^/vnd.ms-powerpoint)|([ca_fileType]^/x-mspowerpoint)][then] > [text]ca_fileExt=ppt[/text][/then] > [else] > > [if ([ca_fileType]^/pdf)][then] > [text]ca_fileExt=pdf[/text][/then] > [else] > > [if > ([ca_fileType]^/x- > compressed)|([ca_fileType]^/x-zip-compressed)|([c > a_fileType]^/zip)|([ca_fileType]^/x-zip)][then] > [text]ca_fileExt=zip[/text][/then] > [else] > > [if ([ca_fileType]^/x-sit)|([ca_fileType]^/x-stuffit)][then] > [text]ca_fileExt=sit[/text][/then] > [else] > > [text > multi=T]ca_linkedError=T&ca_localErr=T&ca_linkedError.[ca_linkedNum]=Linked > file is not a supported type[/text] > > [/else][/if][/else][/if][/else][/if][/else][/if][/else][/if][/else][/if] > [/else][/if][/else][/if][/else][/if] > > > Rob Marquardt > Designer/Resident Wirehead > Toast Design > > 800 Washington Avenue North > Minneapolis MN 55401 > 612.330.9863 v > 612.321.9424 f > www.toastdesign.com ------------------------------------------------------------- This message is sent to you because you are subscribed to the mailing list . To unsubscribe, E-mail to: To switch to the DIGEST mode, E-mail to Web Archive of this list is at: http://search.smithmicro.com/ dale's stuff

DOWNLOAD WEBDNA NOW!

Top Articles:

Talk List

The WebDNA community talk-list is the best place to get some help: several hundred extremely proficient programmers with an excellent knowledge of WebDNA and an excellent spirit will deliver all the tips and tricks you can imagine...

Related Readings:

Forum - Test Request (2005) Problem with Showif & Applescript (1997) [isfile] ? (1997) Where's Cart Created ? (1997) suffix mapping for NT? (1997) Null Characters (2005) [ShowCart] and GET vs. POST (1997) OT-test (1998) Help with update to 2.11 (1998) Emailer Error 550 (Was Strange Crash) (1998) Separate SSL Server (1997) Emailer again & again (1997) Forumulas.db & Variables (2002) [WebDNA] What Webcatalog with Itools?? (2008) Credit Card Number checking (1997) A little syntax help (1997) Smart caching problems with 2.1b3? (1997) [showif] not working (2003) WebCat on Alpha? (1997) Re1000001: Setting up shop (1997)