|
To check size and extension of uploaded files use the following
code in Add page: Before record added
and/or Edit page: Before record
updated events.
Note: Change
the values listed in red to
match your specific needs.
1. Check size and extension of
uploaded files stored on a hard drive
Check file size:
|
mysize=lenb(GetUploadedFileContents("value_FieldName_" & postvalue("id")))
if
mysize>1000000 then
' if file size is greater than 1Mb
message
= "File is too big"
BeforeAdd=false ' or BeforeEdit=false
exit
function
end if
|
Check file extension:
|
exttype =
CheckImageExtension(values("FieldName"))
if
lcase(exttype)=".jpg" or lcase(exttype)=".gif" then
message =
"Wrong file
type selected"
BeforeAdd=false ' or BeforeEdit=false
exit function
end
if
|
2. Check size of uploaded files
stored in a database
|
mysize=lenb(values("FieldName"))
if
mysize>1000000 then ' if file size is greater than 1Mb
message =
"File is too
big"
BeforeAdd=false ' or BeforeEdit=false
exit function
end
if
|
|