Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Senior Coder
    Join Date
    May 2004
    Posts
    1,464
    Thanks
    15
    Thanked 0 Times in 0 Posts

    get name of input file type

    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>
    and
    <input type=file name=file2>

    How can I determine which file was uploaded for file1 and which for file2?

  • #2
    Regular Coder
    Join Date
    Mar 2007
    Posts
    505
    Thanks
    1
    Thanked 19 Times in 19 Posts
    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>"
    Next
    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>"
    Next
    End Sub

    So looking in the loop - anytime you want to see the file names, just look at UploadedFiles.Items.FileName

  • #3
    Senior Coder
    Join Date
    May 2004
    Posts
    1,464
    Thanks
    15
    Thanked 0 Times in 0 Posts
    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)

  • #4
    Regular Coder
    Join Date
    Mar 2007
    Posts
    505
    Thanks
    1
    Thanked 19 Times in 19 Posts
    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...

  • #5
    Senior Coder
    Join Date
    May 2004
    Posts
    1,464
    Thanks
    15
    Thanked 0 Times in 0 Posts
    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??

  • #6
    Regular Coder
    Join Date
    Mar 2007
    Posts
    505
    Thanks
    1
    Thanked 19 Times in 19 Posts
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •