Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8117227
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T04:05:52+00:00 2026-06-06T04:05:52+00:00

I need to be able to send a file to another website from server-side

  • 0

I need to be able to send a file to another website from server-side Classic ASP code. The other website has a form with a file upload control, and I need to simulate posting to this form.

I found some sample code which seemed perfect for the job here, and it uploads the file without error, but the received file is not valid and when I inspect it on the other server the beginning of the file before the binary data has part of the posted data in it that shouldn’t be there, eg:

ntent-Type: image/jpeg
Content-Disposition: form-data; name=”file”; filename=”archivebox.jpg”

ÿØÿà…

The receiving website code works fine when I upload data via a form, so it definately looks like the problem is with the above code.

If this code is not going to work, can anyone else point me in the direction of another sample for submitting files in this way?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T04:05:53+00:00Added an answer on June 6, 2026 at 4:05 am

    Using the code sample in the link in my question, I modified it to build the request manually and it worked. I also converted to a single function that takes a binary file and one parameter and POSTs the request.

    Function PostDocument(intDocumentID, binFile, strFilename, strContentType)
    Dim objHttp, strBoundary, strRequestStart, strRequestEnd, binPost
    Dim objStream
    
    strBoundary = "---------------------------9849436581144108930470211272"
    
    Set objHttp = Server.CreateObject("MSXML2.ServerXMLHTTP.6.0")
    
    strRequestStart = "--" & strBoundary & vbCrlf &_
        "Content-Disposition: form-data; name=""id""" & vbCrlf &_
        vbCrlf &_
        intDocumentID & vbCrlf &_
        vbCrlf &_
        "--" & strBoundary & vbCrlf &_
        "Content-Disposition: form-data; name=""file""; filename=""" & strFilename & """" & vbCrlf &_
        "Content-Type: " & strContentType & vbCrlf &_
        vbCrlf
    
    strRequestEnd = vbCrLf & "--" & strBoundary & "--"
    
    Set objStream = Server.CreateObject("ADODB.Stream")
    
    objStream.Type = adTypeBinary '1
    objStream.Mode = adModeReadWrite '3
    objStream.Open
    objStream.Write StringToBinary(strRequestStart)
    objStream.Write binFile
    objStream.Write StringToBinary(strRequestEnd)
    objStream.Position = 0
    
    binPost = objStream.Read
    
    Response.Write binPost
    
    objStream.Close
    Set objStream = Nothing
    
    objHttp.Open "POST", "(url removed)", False, "(username removed)", "(password removed)"
    objHttp.setRequestHeader "Content-Type", "multipart/form-data; boundary=""" & strBoundary & """"
    objHttp.Send binPost
    
    PostDocument = objHttp.ResponseText
    
    Set objHttp = Nothing
    End Function
    
    Function StringToBinary(toConvert)
    Dim objStream, data
    
    Set objStream = Server.CreateObject("ADODB.Stream")
    
    objStream.Charset = "ISO-8859-1"
    objStream.Type = adTypeText '2
    objStream.Mode = adModeReadWrite '3
    objStream.Open
    objStream.WriteText toConvert
    
    objStream.Position = 0
    objStream.Type = adTypeBinary '1
    StringToBinary = objStream.Read
    
    objStream.Close
    Set objStream = Nothing
    End Function
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to be able to send an email from a silverlight client-side application.
I need to be able to send the content type text/xml to Firefox and
For my application, I need to be able to send an std::vector<std::string> over a
Users of the website need to able to store images in their area ,
I need to be able to start/stop a per-session GUI agent from a root
I've got some code to convert a large (many gigabytes) XML file into another
I am trying to send data from an Android app to a PHP file
I would like to somehow send a file from my app on one android
I need to pass a variable from Admin.java file to index.jsp. I get the
I need to be able to transmit data from a Flash browser application to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.