Upload and resize image using Persits ASPJpeg and ASPUpload

Posted on 2007-10-15
Last Modified: 2008-02-25
I urgently need a complete script to upload a file from a form and then resize that image into 2 seperate files. I need a large file 800 x 600 and then a thumbnail 100 x 75. All images should be are 4 x 3 constraint proportions.

To do this I have the following extensions available to me...

Persits ASPJpeg
Persits ASPUpload

Thanks for your help.
Question by:clearchannel
    LVL 9

    Expert Comment

    Have you written any code yet?  If not, the examples in the manuals for each product should help you get started:


    Of specific interest are the two example:

    '// Uploading an image to a server.

    '// Creating a thumbnail from an uploaded image.

    -= DeathToSpam =-
    LVL 9

    Accepted Solution

    Dim FileName
    Dim FSO
    Dim Jpeg
    Dim newFile
    Dim Upload
    Dim UploadedFile

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

    Upload.OverwriteFiles = False
    FilePath = "D:\upload_location\"
    Set FSO = CreateObject("Scripting.FileSystemObject")
    Set UploadedFile = Upload.Files(1)
    FileName = FilePath & UploadedFile.FileName
    UploadedFile.SaveAs FileName
    Jpeg.Open UploadedFile.FileName
    L = 800
    Jpeg.Width = L
    Jpeg.Height = Jpeg.OriginalHeight * L / Jpeg.OriginalWidth
    Jpeg.Save FilleName
    L = 100
    Jpeg.Width = L
    Jpeg.Height = Jpeg.OriginalHeight * L / Jpeg.OriginalWidth
    FileName = FilePath & Replace(UploadedFile.FileName,".jpg","") & "_small.jpg"
    Jpeg.Save FilleName
    Set Jpeg = Nothing
    Set Upload = Nothing

    LVL 9

    Expert Comment

    Obvioulsy, ditch the extra %> at the end.

    Also, if you have multiple images per page, replace the section in the middle That says:

    Set UploadFile = Upload.Files(1)


    For Each imageFile in Upload.Files
      Set UploadedFile = imageFile

    and put a 'Next' after Jpeg.Close

    Oh, and ditch the line that says FSO =, that was an extra piece of my script that I clipped out. I had my script set to make company name and user name directories in the upload area to put the new images into.

    Author Comment

    Thanks for your help guys. As soon as I test this solution I will award points. :)
    LVL 2

    Expert Comment

    hmmm just a clarification....
    Jpeg.Height = Jpeg.OriginalHeight * L / Jpeg.OriginalWidth
    Jpeg.Save FilleName

    the "FilleName" in that shouldnt that be "Filename"? as no where else is it declaring what file name it should use
    LVL 2

    Expert Comment

    another error... took me a while to figure it out...

    the line "Jpeg.Open UploadedFile.FileName" needs to be "Jpeg.Open FileName" as you're already adding the path above.. i think... anyways this seems to make it work.

    im kinda changing the code so not sure if the default works or not.. just something i saw that didnt look right

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
    This demonstration started out as a follow up to some recently posted questions on the subject of logging in: and…
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    733 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now