05-15-2007, 07:21 PM
i'm using the aspupload script at http://www.freeaspupload.net
(but I think the same question applies to all upload scripts)
if I have a files named
<input type=file name=file1>
<input type=file name=file2>
How can I determine which file was uploaded for file1 and which for file2?
05-15-2007, 07:30 PM
Directly from their documentation:
Public Sub DumpData() 'only works if files are plain text
Dim i, aKeys, f
response.write "Form Items:<br>"
aKeys = FormElements.Keys
For i = 0 To FormElements.Count -1 ' Iterate the array
response.write aKeys(i) & " = " & FormElements.Item(aKeys(i)) & "<BR>"
response.write "Uploaded Files:<br>"
For Each f In UploadedFiles.Items
response.write "Name: " & f.FileName & "<br>" <<<<< This is what you are looking for
response.write "Type: " & f.ContentType & "<br>"
response.write "Start: " & f.Start & "<br>"
response.write "Size: " & f.Length & "<br>"
So looking in the loop - anytime you want to see the file names, just look at UploadedFiles.Items.FileName
05-15-2007, 07:34 PM
no i'm not looking for the filename
basically if i have an input type=file1> and i put in xxx.gif for the upload I want to know when i loop through that file1 was xxx.gif and file2 was yyy.gif --
I need to know which file associates with which input name (and the user can leave one blank so I can't just go by the order)
05-16-2007, 05:20 AM
Ohh... Sorry! Misunderstood...
This usually comes with the Upload system that you are using and whether or not it has the FormItem.FieldName method with it. This also usually only pertains to Non-File item descriptors, as MULTI-PART ENCTYPES do not include the INPUT TYPE=FILE information in the request.form, since it's a STREAM-ing object.
I use ASPUpload for my 3rd party uploader, and it does have the ability to give you the Item.Name and Item.Value, but again, only for Non-File (i.e. plain text) based upload items.
If you wanted to make sure that you had this information, I would add a text "Descriptor" field in your form. That way you can guarantee that you know the field name of the item being uploaded, as well as make sure that you have some idea of the file being uploaded.
Just my $0.02...
05-16-2007, 05:55 AM
so then if i have file1 and file2 -- there is no way of knowing which item is uploaded for file1 and for file2? this sounds like something that would be available.
How would a descriptive field help? I mean i still won't know which image was uploaded??
05-16-2007, 01:11 PM
If you do error checking, then you know that if Descr1 <> "", you can use your upload script to set the name of the file to be File1-Descr1. That way you know which file was uploaded via the correct slot.
It's not perfect, but it's a start. Again, it's not available because that information is not kept in the ENCTYPE as regular text form data is.
Try this -- write a small form (2 or 3 fields) and on your submit response.write request.form. Then change one of those fields to INPUT TYPE=FILE. You will see that the information doesn't get posted.
I know, it should be available, and if you have access to installing DLLs on your server, you may want to try another product that has the methods (INPUT fieldName) that you are looking for.