Contents

 
Home
ASPRunner Professional 7.1 manual
Prev Page Next Page
 
 

Check size and extension of uploaded files

 

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.

yellowbulbNote: 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

Converted from CHM to HTML with chm2web Standard 2.85 (unicode)