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
|