This topic is locked

File Upload Size Limit

4/7/2006 9:27:34 AM
ASPRunnerPro General questions
T
techno author

Hi, Sergey:
I would like to limit the size of a file upload to 25 megs. Is there a way to do this is ASPRunnerPro version 3.2?
Thanks in advance,

Marie

Sergey Kornilov admin 4/7/2006

Marie,
you can try something like this. I've bolded new code. Make sure you changed both Edit and Add pages.

if lenb(strValue)<25000000 then

rs("Picture").AppendChunk strValue

else

Response.Write "File size is too large"

end if

T
techno author 4/7/2006

Marie,

you can try something like this. I've bolded new code. Make sure you changed both Edit and Add pages.


Thanks Sergey:
I am trying it now. One more questions, can I limit the file to be uploaded to a text .txt file only?

Thanks again!

Marie

Sergey Kornilov admin 4/10/2006

Marie,
To limit the type of uploaded file to txt do the following:

  • open ..._add.asp or ..._edit.asp file with any text editor
  • find this code snippet (where Field is your field name):
    if GetRequestForm("typeField") = "upload2" then

    rs("Field")= strValue

    if strValue<>"" then _

    WriteToFile Server.MapPath(GetUploadFolder("Field") & strValue), GetRequestForm("fileField")

    end if


  • and replace it with this one
    if GetRequestForm("typeField") = "upload2" then

    nPoint=instrrev(strValue,".")

    strExtension=""

    if nPoint>0 then strExtension=LCase(Mid(strValue,nPoint+1))

    if strExtension="txt" then

    rs("Field")= strValue

    if strValue<>"" then _

    WriteToFile Server.MapPath(GetUploadFolder("Field") & strValue), GetRequestForm("fileField")

    end if

    end if