SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Apr 2011
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Dundas upload and no file fields

    Hi there.

    I am trying to upload a file and process other form entries using Dunas upload. For some reason ALL fields are being ignored. I have a short piece of code I wrote to test this but the results come back empty.

    Here is the coding for the pages:

    Form page:

    <form method="post" action="test.asp" EncType="Multipart/Form-Data">
    Photo: <input name="photo" type="file"><br>
    Any text: <input name="stuff" type="text"><br>
    <input name="Submit1" type="submit" value="submit">
    <input type="hidden" name="action" value="process">
    </form>


    Form hadling page:

    dim objUpload, StrAction, StrStuff

    Set objUpload = Server.CreateObject("Dundas.Upload.2")

    StrAction= objUpload.Form("action")
    StrStuff = objUpload.Form("stuff")
    Response.write "Action: " & StrAction
    Response.write "Stuff: " & StrStuff
    For Each objFormItem In objUpload.Form
    Response.write objFormItem.Value
    next


    This returns no values at all. The looping doesn't even parse once; I put an alert inside to test this.

    Thanks for any help

  2. #2
    #titanic {float:none} silver trophy
    molona's Avatar
    Join Date
    Feb 2005
    Location
    from Madrid to Heaven
    Posts
    8,236
    Mentioned
    239 Post(s)
    Tagged
    1 Thread(s)
    I don't a clue about this as I don't use ASP as my main programming language and I've forgotten a lot of stuff but comparing this example with others I've googled, it looks different.

    True, most of the examples where loading files into a directory which you don't seem to have, and none of them save the specific values into variables, something that you've done at the very beginning.

    Since I don't know how the object works, I find a bit puzzling to find objUpload.Form ("action")... isn't this the action or page where the data is sent for processing?

    And then, ojbUpload.Form("stuff") which seems to be a specific field from your form.

    Look at this example

    Code asp:
    <%
    Set objUpload = Server.CreateObject ("Dundas.Upload.2")
    objUpload.Save "c:\temp\"
    For Each objUploadedFile in objUpload.Files
    Response.Write "<br>
    The " & objUploadedFile.TagName & " file input box was used to upload a file."
    Next
     
     
    '*************************************
    For Each objFormItem In objUpload.Form
    Response.Write "<br>
    The name of the form item is: " & objFormItem
    Response.Write "<br>
    The value of the form item is: " & objFormItem.Value & "<br>
    "
    Next
    '*******************************************
    Set objUpload = Nothing
    %>

    the code assumes that your form is being sent as multipart/data. Probably, the part that you will find more interesting is what I put between the * which seems to be similar to what your doing.

  3. #3
    SitePoint Member
    Join Date
    Apr 2011
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Malona,

    Thanks for replying.

    What you gave me was pretty much I had already culled from Dundas' own documentation and points accross the web, but thanks nevertheless.

    The objUpload.Form ("action") is atually pretty simple. It's a hidden form field which tells the form handler to process either a new record (action="insert") or to update an existing record (action="update"). Simple as that.

    I did work out what I was doing wrong, and that was not saving the data before trying to implement further object methods etc. I have it all worked out now but if took me a further 3 hours!

    Thanks for your input anyway.


Bookmarks

Posting Permissions

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