AspJpeg

Discussion in 'ASP General' started by Christopher Brandsdal, Jul 31, 2003.

  1. Hello!
    I am making a upload script for my images. I want the script to resize the
    images automaticly.
    The server supports AspJpeg but i don't have AspUpload.

    Can anyone help me to implement the AspJpeg code into my upload code?


    AspJpeg CODE.
    '---------------------------------------------------------------------------
    -----------------------
    ' create instance of AspJpeg object
    Set jpeg = Server.CreateObject("Persits.Jpeg")

    ' open uploaded file
    jpeg.Open( File.Path )

    ' resize image accoring to "scale" option.
    ' notice that we cannot use Request.Form, so we use Upload.Form instead.
    jpeg.Width = jpeg.OriginalWidth * Upload.Form("scale") / 100
    jpeg.Height = jpeg.OriginalHeight * Upload.Form("scale") / 100

    SavePath = Server.MapPath("/bilde/") & File.ExtractFileName

    ' AspJpeg always generates JPEG thumbnails regardless of original format.
    ' If the original file was not a JPEG, append .JPG extension.
    If UCase(Right(SavePath, 3)) <> "JPG" Then
    SavePath = SavePath & ".jpg"
    End If

    jpeg.Save SavePath
    '---------------------------------------------------------------------------
    ----------------------



    MY UPLOAD CODE




    '---------------------------------------------------------------------------
    ----------------

    if Request.QueryString("action") = "upload" then
    Server.ScriptTimeout = 1200
    Response.Expires = 0
    Response.Buffer = TRUE
    Response.Clear

    Dim UploadRequest
    Set UploadRequest = CreateObject("Scripting.Dictionary")

    ByteCount = Request.TotalBytes

    if ByteCount > Application("MaxFileSize2Upload") then
    Response.Redirect "./select_image.asp?error=05"
    end if


    RequestBin = Request.BinaryRead(byteCount)
    BuildUploadRequest RequestBin

    Dim aux, aux1
    Dim ImageCateg, ContentType, FilePathName, FileName, Value

    ImageCateg = Unescape(UploadRequest.Item("inpcatid").Item("Value")) 'Image
    Folder

    on error resume next
    ContentType = UploadRequest.Item("inpFile").Item("ContentType")
    FILEFLAG = err.number
    on error goto 0

    if FILEFLAG = 0 then
    ContentType = UploadRequest.Item("inpFile").Item("ContentType")
    FilePathName = UploadRequest.Item("inpFile").Item("FileName")
    FileName =
    Right(filepathname,Len(filepathname)-InstrRev(filepathname,"\"))
    Value = UploadRequest.Item("inpFile").Item("Value")
    else
    FileName = ""
    end if

    Dim objFSO2
    Dim objUploadFile

    if FileName<>"" then
    on error resume next
    Set objFSO2 = Server.CreateObject("Scripting.FileSystemObject")
    Set objUploadFile = objFSO2.CreateTextFile(ImageCateg&"\"&FileName)
    objUploadFile.Write getString(value)
    objUploadFile.Close
    FILEFLAG = err.number
    on error goto 0
    end if

    Set objFSO2 = nothing
    Set objUploadFile = nothing
    Set UploadRequest = nothing

    if FILEFLAG = 0 then
    sUrl = "./select_image.asp?catid=" & Escape(ImageCateg) & "&dir=" &
    Escape(sDir) & "&fld=" & Escape(sField)
    else
    sUrl = "./select_image.asp?error=02"
    end if

    Response.Redirect sUrl
    End If


    '---------------------------------------------------------------------------
    ----------------
     
    Christopher Brandsdal, Jul 31, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Tony
    Replies:
    3
    Views:
    3,405
  2. Tony
    Replies:
    0
    Views:
    545
  3. Tony

    ASPJPEG in vb.net ???

    Tony, Apr 26, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    2,373
    Kevin Spencer
    Apr 26, 2005
  4. ASPJPEG Help

    , Oct 6, 2005, in forum: ASP General
    Replies:
    1
    Views:
    159
Loading...

Share This Page