How to send a form with binary data to another server?

Discussion in 'ASP General' started by ij, Nov 26, 2003.

  1. ij

    ij Guest

    Hi,

    I'm trying to submit an image object, along with some other text fields to
    another web server from within an ASP page but am stuck on getting the image
    to be submitted with the form.

    In a bit more detail:
    1. When this particular page is executed, I want the server to pull an image
    from a db (stored as a BLOB) along with a few other text fields. This part
    is easy and I have no problems with it.
    2. I want to submit the image, along with the text fields to a second
    webserver which typically accepts its input from a form (ie, the second
    webserver usually has a webpage where a user enters some information into
    form and browse for a file. When clicking submit, the form fields along with
    the file are submitted to the second server).

    The reason for this is that I'm trying to migrate from one web based photo
    album to another which uses a data structure that is complicated and
    difficult to interface with, so I'm using the web based image upload
    functionality of the new album.

    Doing the above steps without the image / BLOB is fairly easy, and I have
    successfully migrated the album info across using the code at the end of
    this message.

    The problem is doing the same but also submitting a BLOB.
    I'm extremely stuck and any help would be very much appriciated.

    Cheers,
    Kent

    Code:

    strSQL = "SELECT Name, Description, Date, Owner_ID, id, category_id,
    Parent_Album FROM photo_album WHERE ID =" + Request.QueryString("id") + ";"
    Set objConn = Server.CreateObject("ADODB.Connection")
    objConn.CommandTimeout = 120
    objConn.ConnectionTimeout = 120
    objConn.Open strConn
    Set objRS = Server.CreateObject("ADODB.Recordset")
    objRS.CursorLocation = 3
    objRS.Open strSQL,objConn,2,2,1

    if cint(objRS.fields("Parent_Album")) = 0 then
    url = baseUrl & "cmd=new-album&protocol_version=2.1&set_albumName=" &
    objRS.fields("category_id")
    else
    url = baseUrl & "cmd=new-album&protocol_version=2.1&set_albumName=" &
    objRS.fields("Parent_Album")
    end if
    url = url & "&newAlbumName=" & objRS.fields("id")
    url = url & "&newAlbumTitle=" & objRS.fields("Name")
    url = url & "&newAlbumDesc=" & objRS.fields("date") &
    objRS.fields("Description")
    response.write(url)
    response.write("<br><br>")

    objXmlHttp.open "GET", url, False
    objXmlHttp.send
    ij, Nov 26, 2003
    #1
    1. Advertising

  2. you to specify the enctype property of the form to
    "multipart/formdata"

    --
    Roji. P. Thomas
    SQL Server Programmer ;)
    ________________________
    "ij" <ok> wrote in message
    news:3fc4898a$0$13681$...
    > Hi,
    >
    > I'm trying to submit an image object, along with some other text fields to
    > another web server from within an ASP page but am stuck on getting the

    image
    > to be submitted with the form.
    >
    > In a bit more detail:
    > 1. When this particular page is executed, I want the server to pull an

    image
    > from a db (stored as a BLOB) along with a few other text fields. This part
    > is easy and I have no problems with it.
    > 2. I want to submit the image, along with the text fields to a second
    > webserver which typically accepts its input from a form (ie, the second
    > webserver usually has a webpage where a user enters some information into
    > form and browse for a file. When clicking submit, the form fields along

    with
    > the file are submitted to the second server).
    >
    > The reason for this is that I'm trying to migrate from one web based photo
    > album to another which uses a data structure that is complicated and
    > difficult to interface with, so I'm using the web based image upload
    > functionality of the new album.
    >
    > Doing the above steps without the image / BLOB is fairly easy, and I have
    > successfully migrated the album info across using the code at the end of
    > this message.
    >
    > The problem is doing the same but also submitting a BLOB.
    > I'm extremely stuck and any help would be very much appriciated.
    >
    > Cheers,
    > Kent
    >
    > Code:
    >
    > strSQL = "SELECT Name, Description, Date, Owner_ID, id, category_id,
    > Parent_Album FROM photo_album WHERE ID =" + Request.QueryString("id") +

    ";"
    > Set objConn = Server.CreateObject("ADODB.Connection")
    > objConn.CommandTimeout = 120
    > objConn.ConnectionTimeout = 120
    > objConn.Open strConn
    > Set objRS = Server.CreateObject("ADODB.Recordset")
    > objRS.CursorLocation = 3
    > objRS.Open strSQL,objConn,2,2,1
    >
    > if cint(objRS.fields("Parent_Album")) = 0 then
    > url = baseUrl & "cmd=new-album&protocol_version=2.1&set_albumName=" &
    > objRS.fields("category_id")
    > else
    > url = baseUrl & "cmd=new-album&protocol_version=2.1&set_albumName=" &
    > objRS.fields("Parent_Album")
    > end if
    > url = url & "&newAlbumName=" & objRS.fields("id")
    > url = url & "&newAlbumTitle=" & objRS.fields("Name")
    > url = url & "&newAlbumDesc=" & objRS.fields("date") &
    > objRS.fields("Description")
    > response.write(url)
    > response.write("<br><br>")
    >
    > objXmlHttp.open "GET", url, False
    > objXmlHttp.send
    >
    >
    Roji. P. Thomas, Nov 26, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Andrea De Santi

    Send form data to another page

    Andrea De Santi, Mar 5, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    10,024
    Andrea De Santi
    Mar 5, 2005
  2. ouz as
    Replies:
    3
    Views:
    668
    Diez B. Roggisch
    Dec 13, 2004
  3. ouz as
    Replies:
    1
    Views:
    925
    Diez B. Roggisch
    Dec 14, 2004
  4. Fredrik Lundh
    Replies:
    1
    Views:
    4,045
    Scott David Daniels
    Dec 15, 2004
  5. ij
    Replies:
    0
    Views:
    103
Loading...

Share This Page