Click to See Complete Forum and Search --> : Problem with a loop - please help


weee
10-13-2004, 03:09 PM
Hi There.

I have a loop that uploads photos. The thing is that I'm trying to run the loop and also get the name of each photo that I'm uploading (so I can insert into a database).


For Each File in Upload.Files

Set File = Upload.Files(1)
If File.ImageType = "UNKNOWN" Then
File.Delete
Else
Height = File.ImageHeight
Width = File.ImageWidth
Set Jpeg = Server.CreateObject("Persits.Jpeg")
Path = Server.MapPath("images/") & "/" & File.ExtractFileName

Jpeg.Open Path

Jpeg.OpenBinary Upload.Files(1).Binary
Jpeg.PreserveAspectRatio = True
Jpeg.Height = 100
Jpeg.Width = 200
Jpeg.Save "D:\html\users\images\small\" & File.Filename

Jpeg.OpenBinary Upload.Files(1).Binary
Jpeg.PreserveAspectRatio = True
Jpeg.Height = 200
Jpeg.Width = 400
Jpeg.Save "D:\html\users\images\big\" & File.Filename
End If

Next


I'll have something like that:
image1 = File.ExtractFileName

I'll get the name of the first photo that I'm uploading but I want to get the name of all of'em. I tried so many things... what can I do?
Please help.

Thanks a lot!

CardboardHammer
10-13-2004, 04:49 PM
For Each File in Upload.Files

If File.ImageType = "UNKNOWN" Then
File.Delete
Else
Height = File.ImageHeight
Width = File.ImageWidth
Set Jpeg = Server.CreateObject("Persits.Jpeg")
Path = Server.MapPath("images/") & "/" & File.ExtractFileName

Jpeg.Open Path

Jpeg.OpenBinary File.Binary
Jpeg.PreserveAspectRatio = True
Jpeg.Height = 100
Jpeg.Width = 200
Jpeg.Save "D:\html\users\images\small\" & File.Filename

Jpeg.OpenBinary File.Binary
Jpeg.PreserveAspectRatio = True
Jpeg.Height = 200
Jpeg.Width = 400
Jpeg.Save "D:\html\users\images\big\" & File.Filename
End If

Next


You kept slapping the 1st file on top of itself by doing things like
Set File = Upload.Files(1) File was already set in the For statement.

weee
10-13-2004, 08:06 PM
That I don't know how to get the name of the first and the second photo and so on...

buntine
10-13-2004, 08:24 PM
So what does File.FileName return? You were already using that, werent you?

weee
10-14-2004, 12:19 AM
name of the first file but I'm not sure how to get the rest...