This topic is locked

limit the size of uploaded image

9/28/2005 08:48:50
ASPRunnerPro General questions
author

Hi, Sergey:
I have integrated the image upload into one of my systems. However, I want to limit the size of the image or perhaps resize upon upload it without distorting it. Also, can I limit the type of file uploaded to gif jpg. Can someone upload something other than an image to be malicious?
Thanks,

Marie

Sergey Kornilov admin 9/29/2005

Hi,
we'll add resize option in one of the following versions of ASPRunnerPro.
To limit the type of uploaded file to gif / jpg do the following:

  • open ..._add.asp or ..._edit.asp file with any text editor
  • find this code snippet (where Fieldis 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="gif" or strExtension="jpg" then

    rs("Field")= strValue

    if strValue<>"" then _

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

    end if

    end if