There are a couple of modules that might help, described in the accepted 
answer here: 
http://stackoverflow.com/questions/10937350/how-to-check-type-of-files-without-extensions-in-python

On Thursday, October 31, 2013 10:18:58 PM UTC, Claudio Dusan Vega 
Ozuljevich wrote:
>
> how to? do I have to use a module or web.py? Also, the file is in 
> memory, as uploaded (in order to validate it) by a template (html 
> using <input type=file>). 
>
> Thanks for the fast response. 
>
> On Thu, Oct 31, 2013 at 7:08 PM, Steven Brown 
> <[email protected]<javascript:>> 
> wrote: 
> > You could look at file signatures: 
> > 
> > https://en.wikipedia.org/wiki/List_of_file_signatures 
> > 
> > Of course that doesn't guaruntee that the file is valid/conforms to the 
> > format. 
> > 
> > 
> > On 10/31/2013 02:32 PM, Claudio Dusan Vega Ozuljevich wrote: 
> >> 
> >> Hi guys! 
> >> 
> >> Sorry for the noob question, but I just learned programming and I'm 
> >> still struggling to get the hang of it. 
> >> 
> >> I need to know if there is a way to check the file type (pdf, doc, 
> >> jpeg etc) of an uploaded file, so I can store it just if it complies 
> >> with my requirements. Fo example, I want to check if a file is an 
> >> image (jpeg), an in case it is store it and in case it isn't just show 
> >> an error message. 
> >> 
> >> I'm not referring the issue as "the extension" of the file, because 
> >> the extension can be change and file would still be a .exe but just 
> >> with the ".jpeg" extension. 
> >> 
> >> Thanks beforehand. 
> >> 
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> Groups 
> > "web.py" group. 
> > To unsubscribe from this group and stop receiving emails from it, send 
> an 
> > email to [email protected] <javascript:>. 
> > To post to this group, send email to [email protected]<javascript:>. 
>
> > Visit this group at http://groups.google.com/group/webpy. 
> > For more options, visit https://groups.google.com/groups/opt_out. 
>

-- 
You received this message because you are subscribed to the Google Groups 
"web.py" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/webpy.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to