Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 26th, 2007, 04:18 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 347
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Adam H-W
Default Uploading multiple images

I'm using the asp upload component to upload multiple images. I have 5 images - if I upload an image 3 for example, then it assumes the place of image 1, if I upload image 4, then it assumes the place of image 2 - so they don't reside in the postion that I ask them to - here is my code: (the code inserts the product name into an MS SQL Server db)

    For i = 1 to Count
        '---------------------------------------------
        'Obtain File object representing uploaded file
        '---------------------------------------------
         Set File = Upload.Files(i)

        If File.ImageType <> "JPG" Then
%>
<script language="JavaScript">
window.alert("The Selected Image has to be a JPEG Image!");
history.go(-1);
</script>
<%
        end if

                        Set jpeg = Server.CreateObject("Persits.Jpeg")
                        Set jpeg2 = Server.CreateObject("Persits.Jpeg")

                        jpeg.Open(File.Path)
                        jpeg2.Open(File.Path)

                        theWidthRatio = 150/jpeg.OriginalWidth
                        if CDbl(theWidthRatio) < 1 then
                            jpeg.Width = 150
                            jpeg.Height = CInt(jpeg.OriginalHeight * theWidthRatio)
                            jpeg.Save server.Mappath("../../images/upload") & "/small_" & File.ExtractFileName
                        else
                            jpeg.Save server.Mappath("../../images/upload") & "/small_" & File.ExtractFileName
                        end if

                        theBigWidthRatio = 500/jpeg2.OriginalWidth
                        if CDbl(theBigWidthRatio) < 1 then
                            jpeg2.Width = 500
                            jpeg2.Height = CInt(jpeg2.OriginalHeight * theBigWidthRatio)
                            jpeg2.Save server.Mappath("../../images/upload") & "/big_" & File.ExtractFileName
                        else
                            jpeg2.Save server.Mappath("../../images/upload") & "/big_" & File.ExtractFileName
                        end if

                        set jpeg = nothing
                        set jpeg2 = nothing

        if i = 1 then
            rs("ProductImage") = File.ExtractFileName
        elseif i = 2 then
            rs("ProductImage2") = File.ExtractFileName
        elseif i = 3 then
            rs("ProductImage3") = File.ExtractFileName
        elseif i = 4 then
            rs("ProductImage4") = File.ExtractFileName
        elseif i = 5 then
            rs("ProductImage5") = File.ExtractFileName

        end if


can someone explain to me why this is happening?

thanks

Adam






Similar Threads
Thread Thread Starter Forum Replies Last Post
uploading images with PHP Adam H-W PHP How-To 1 May 30th, 2006 10:11 AM
uploading, retrieving images kourosh Classic ASP Basics 2 September 17th, 2005 04:33 PM
uploading Images.. Pallav Servlets 4 November 1st, 2004 05:34 AM
Uploading images to a database vivi Classic ASP Basics 3 October 30th, 2003 10:14 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.