Overview of features
Home
Read this first
About
web2py is 100% free
Download
Start learning web2py today
Documentation
Authors and contributors
Staff
Affiliated companies
Support
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))