tags:

views:

528

answers:

1

Can the clsupload.asp directly replace the persits code? I am a total nubee to coding. tks...

I inherited a website and discovered that they used a com object "persits upload. I do not want to purchase and install for one application. Can someone help to tell me where or how to change this below code to work without the software buy? See line 32 where it says:

Set Upload = Server.CreateObject("Persits.Upload")

Thanks!

<!--#include file="myMod.asp"-->

<%
    'Dim ClassCode
    ' ClassCode = Request.QueryString("CAT")
    'Dim keyWords
    ' keyWords = Trim(Request.QueryString("KEY"))
    'Dim nPage
    ' nPage = CLng(Request.QueryString("Page"))
    Dim grpCode
     grpCode = Trim(Request.QueryString("GRP"))
    Dim grpName
     grpName = Trim(Request.QueryString("GRPNAME"))
    Dim catCode
     catCode = Trim(Request.QueryString("CAT"))
    Dim catName
     catName = Trim(Request.QueryString("CATNAME"))
    Dim catCTR
     catCTR = CLng(Request.QueryString("CTR"))
    Dim catSCTR
     catSCTR = CLng(Request.QueryString("SUBCTR"))
    Dim keyWords
     keyWords = Trim(Request.QueryString("KEY"))
    Dim nPage
     nPage = CLng(Request.QueryString("Page"))

    Dim i
    Dim tmpTxt, tmpTxt2
    Dim strTxt
    Dim File
    Dim Filename
    Dim Upload
    Set Upload = Server.CreateObject("Persits.Upload")
    Upload.SetMaxSize 1000000, True
    Upload.Save

    If Upload.Form("ProductNo") <> "" then
     'AND Upload.Form("ClassCode") <> "" AND Upload.Form("ProductName") <> "" AND Upload.Form("PriorityNo") <> "" then
     'save record
     ReDim arrTxt(1,22)
     arrTxt(0,0) = Trim(Upload.Form("ProductNo"))

     'If catCTR >=1 then
      For i = 1 to catCTR
       if Upload.Form("cat" & i & "") <> "" then
        tmpTxt = tmpTxt & Upload.Form("cat" & i & "") & ", "
       end if
      Next
     'end if

     'If catSCTR >=1 then
      For i = 1 to catSCTR
       if Upload.Form("subcat" & i & "") <> "" then
        tmpTxt2 = tmpTxt2 & Upload.Form("subcat" & i & "") & ", "
       end if
      Next
     'end if

     arrTxt(0,1) = grpCode & "-" & tmpTxt
     'arrTxt(0,2) = Trim(Upload.Form("SubClassCode"))
     arrTxt(0,2) = tmpTxt2
     arrTxt(0,3) = Trim(Upload.Form("ProductName"))
     arrTxt(0,4) = Trim(Upload.Form("Description"))
     arrTxt(0,5) = Trim(Upload.Form("Dimension"))
     arrTxt(0,6) = Trim(Upload.Form("Weight"))
     arrTxt(0,7) = Trim(Upload.Form("Qty1"))
     If Trim(Upload.Form("Price1")) <> "" then
      arrTxt(0,8) = Trim(Upload.Form("Price1"))
     Else
      arrTxt(0,8) = "0.00"
     End if
     arrTxt(0,9) = Trim(Upload.Form("Qty2"))
     If Trim(Upload.Form("Price2")) <> "" then
      arrTxt(0,10) = Trim(Upload.Form("Price2"))
     Else
      arrTxt(0,10) = "0.00"
     End if
     arrTxt(0,11) = Trim(Upload.Form("Qty3"))
     If Trim(Upload.Form("Price3")) <> "" then
      arrTxt(0,12) = Trim(Upload.Form("Price3"))
     Else
      arrTxt(0,12) = "0.00"
     End if
     arrTxt(0,13) = Trim(Upload.Form("Qty4"))
     If Trim(Upload.Form("Price4")) <> "" then
      arrTxt(0,14) = Trim(Upload.Form("Price4"))
     Else
      arrTxt(0,14) = "0.00"
     End if
     arrTxt(0,15) = Trim(Upload.Form("Qty5"))
     If Trim(Upload.Form("Price5")) <> "" then
      arrTxt(0,16) = Trim(Upload.Form("Price5"))
     Else
      arrTxt(0,16) = "0.00"
     End if
     If Trim(Upload.Form("PriorityNo")) <> "" then
      arrTxt(0,17) = Trim(Upload.Form("PriorityNo"))
     Else
      arrTxt(0,17) = "0.00"
     End if

     arrTxt(0,19) = Trim(Upload.Form("Remarks"))
     If Ucase(Upload.Form("status")) = "YES" then
      arrTxt(0,20) = "YES"
     Else
      arrTxt(0,20) = "NO"
     End if

     arrTxt(0,21) = Trim(Upload.Form("DisCode"))

     ' Check whether a file was selected
     Set File = Upload.Files("attach1")
     If Not File Is Nothing Then
      'Obtain and rename file name
      Filename = arrTxt(0,0) & ".jpg" '& Right(file.Filename,3)
      File.SaveAs Server.MapPath("..") & "\giftbasket\thumbs\" & Filename
      arrTxt(0,18) = Ucase(Filename)

      Dim Jpeg
      Set Jpeg = Server.CreateObject("Persits.Jpeg")

      ' Compute path to source image
      Dim Path
      Path = Server.MapPath("..") & "\giftbasket\thumbs\" & arrTxt(0,18)

      ' Open source image
      Jpeg.Open Path

      ' Decrease image size by 15%
      'Jpeg.Width = Jpeg.OriginalWidth * 15 / 100
      'Jpeg.Height = Jpeg.OriginalHeight * 15 / 100

      'Fixed width and height in ratio with the given width
      Jpeg.Width = 150
      Jpeg.Height = Jpeg.OriginalHeight * Jpeg.Width / Jpeg.OriginalWidth

      ' create thumbnail and save it to disk
      Jpeg.Save Server.MapPath("..") & "\giftbasket\thumbs\" & arrTxt(0,0) & "sml.jpg"   
     Else
      'no file selected
      arrTxt(0,18) = Request.QueryString("IMG")
     End If

     'response.Write(Trim(Upload.Form("ClassCode")))
     call mySave("SELECT * FROM PRDMaster WHERE ProductNo='" & Replace(arrTxt(0,0),"'","''") & "'", 0, 21)
     ReDim arrTxt(1,21)

     'Response.Write("<b>You have successfully saved the record!</b><br><br>Please wait while redirecting the page...")
     'Response.AddHeader " REFRESH" , " 2;url=prdedit.asp?ID=" & Trim(Upload.Form("ProductNo"))
     'Response.Redirect("prdedit.asp?ID=" & Trim(Upload.Form("ProductNo")))
     Response.Redirect("prdsetup.asp?CAT=" & catCode & "&CATNAME= " & catName & "&GRP=" & grpCode & "&GRPNAME=" & grpName & "&Page=" & nPage & "&KEY=" & keyWords & "")
    Else
     'Response.Write("<b>No record was save!</b><br><br>Please wait while redirecting the page...")
     'Response.AddHeader " REFRESH" , " 2;url=prdedit.asp?ID=" & Trim(Upload.Form("ProductNo"))
     'Response.Redirect ("prdedit.asp?ID=" & Trim(Upload.Form("ProductNo")))
     Response.Redirect("prdsetup.asp?CAT=" & catCode & "&CATNAME= " & catName & "&GRP=" & grpCode & "&GRPNAME=" & grpName & "&Page=" & nPage & "&KEY=" & keyWords & "")
    End If
%>
+1  A: 

Check this link and this

Shoban