Reading image dimensions before it is loaded from a web form using python.



Hello,
I am writing an application using python that allows the user to upload
an image to a folder on the server.

Is there a way to get the size of the file before it has been uploaded
onto the server and give an error if the size does not comply to the
maximum size.

So far, my apps loads the image and checks it and then returns an error
if the image is too big. Which is a bit pointless in that I should be
able to get the file info before it is loaded, but I am not sure where
to go.

PIL reads the image size before it is loaded, but this is when I run
this on my local machine. There is also a post
http://mail.python.org/pipermail/python-list/2005-May/323018.html by
Will McGugan where he loads 1px and rejects it if its too big. But his
apps is an image scraper, so I suppose it fits his use case where he
checks the size and then pulls the image if it fits.

Anyone with ideas on how to deal with this.

Thanks

Norman

.



Relevant Pages

  • Re: File Upload - Security Issues
    ... You want to upload a file for what reason and ... these viruses have less chance of being able to execute (even if succeeded ... :> file and what pitfalls you see re: security might be helpful on this ... :>: files to an IIS server that doesn't have MS Office actually installed? ...
    (microsoft.public.scripting.vbscript)
  • Re: File Upload - Security Issues
    ... uploaded and the user could upload any or all of these in theory. ... There is no one product that can give you 100% security, ... > Code doesn't execute in local memory space unless remote user has rights ... > You don't have MS Office installed on the server. ...
    (microsoft.public.scripting.vbscript)
  • pure-ftp nologin
    ... I have a server running FreeBSD 6.3. ... # If you want to enable PAM authentication, ... AnonymousCanCreateDirs no ... # Disallow anonymous users to upload new files ...
    (comp.unix.bsd.freebsd.misc)
  • [NT] DeskNow Mail and Collaboration Server Directory Traversal Vulnerabilities
    ... The following security advisory is sent to the securiteam mailing list, and can be found at the SecuriTeam web site: http://www.securiteam.com ... Collaboration Server is "a full-featured and integrated mail and instant ... attachment upload feature that may be exploited to upload files to ... * DeskNow Mail and Collaboration Server version 2.5.12 and prior ...
    (Securiteam)
  • Re: [Full-disclosure] phpBB 2.0.17 (and other BB systems as well) Cookie disclosure exploit.
    ... app that allows the user to upload an image of some type. ... Internet Explorer ignores the content type sent by the web server and ... > HTML code instead. ... > upload it as a phpBB avatar. ...
    (Full-Disclosure)