AlterEgo
old web2py blog
Useful Links
List all entries
Book
Interactive Examples
F.A.Q.
Free Applications
Plugins
Recipes
Demo of Admin Interface
Semantic web extension
Some of the information here may be outdated, please check the book instead
Edit page
Title:
Security Code:
Body:
(use
this
wiki markup)
New IS_UPLOAD_FILENAME validator checks if name and extension of file uploaded through file input matches given criteria. Note that this does *not* ensure the file type in any way. String is partitioned into name and extension parts by splitting it with dot character. INPUT(_type='file', _name='name', requires=IS_UPLOAD_FILENAME(filename=None, extension=None, lastdot=True, case=1)) 1. filename: filename (before dot) regular expression text 2. extension: extension (after dot) regular expression text 3. lastdot: which dot should be used as a filename / extension separator: True means last dot, eg. file.png -> file / png, False means first dot, eg. file.tar.gz -> file / tar.gz 4. case: 0 - keep the case, 1 - transform the string into lowercase (default), 2 - transform the string into uppercase If there is no dot present, extension checks will be done against empty string and filename checks against whole value. Examples: Check if file has a pdf extension (case insensitive): INPUT(_type='file', _name='name', requires=IS_FILENAME(extension='pdf')) Check if file has a tar.gz extension and name starting with backup: INPUT(_type='file', _name='name', requires=IS_FILENAME(filename='backup.*', extension='tar\.gz', lastdot=False)) Check if file has no extension and name matching README (case sensitive): INPUT(_type='file', _name='name', requires=IS_FILENAME(filename='^README$', extension='^$', case=0))
© 2008-2010 by Massimo Di Pierro - All rights reserved - Powered by
web2py
- design derived from a theme by
the earlybird
The content of this book is released under the
Artistic License 2.0
- Modified content cannot be reproduced.