?
Solved

Send data to asp page

Posted on 2004-10-05
4
Medium Priority
?
173 Views
Last Modified: 2010-05-02
i am using this function

Private Sub upload(filename As String)

    On Error GoTo ErrHandler

    Dim aPostData() As Byte
    Dim vPostData As Variant
    Dim vUrl As Variant
    Dim vHeaders As Variant
    Dim strText As String
    Dim strContentHeader As String
    Dim strBody As String
    Dim nFile As Integer

    strContentHeader = "Content-Type: text/plain" & vbCrLf
    'read the whole file
    nFile = FreeFile
    Open filename For Binary As #nFile
    strText = String(LOF(nFile), " ")
    Get #nFile, , strText
    Close #nFile
    'http header
    vHeaders = "Content-Type: multipart/form-data, boundary=AaB03x" & vbCrLf
    'assemble the body. send one field and one file
    strBody = ""
   
    strBody = strBody & "--AaB03x" & vbCrLf
    strBody = strBody & "Content-Disposition: attachment; name=""FILE1""; filename=""" & filename & """" & vbCrLf
    strBody = strBody & strContentHeader & vbCrLf
    strBody = strBody & strText & vbCrLf
    strBody = strBody & "--AaB03x--"
    'must convert to byte array
    aPostData = StrConv(strBody, vbFromUnicode)
    vPostData = aPostData
    'post to...
    vUrl = "http://........................asp"
    'Do it!
    WebBrowser1.Navigate vUrl, 0, "", vPostData, vHeaders
    Exit Sub
ErrHandler:
    Err.Clear
    upload filename
    Close #nFile
    Exit Sub
End Sub


it works just like it i had a form like the following

<FORM name="send" method="post" encType="multipart/form-data" action="http://....asp">
      <INPUT type="File" name="File1" size="20">
      <INPUT type="Submit" value="Upload">
</FORM>


it works fine

but i want to add a field to it

like the form

<FORM name="send" method="post" encType="multipart/form-data" action="http://....asp">
      <INPUT type="hidden" name="firstname" value="gerald">
                 <INPUT type="File" name="File1" size="20">
      <INPUT type="Submit" value="Upload">
</FORM>

thanks in advance
0
Comment
Question by:gezzuzz
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 17

Accepted Solution

by:
zzzzzooc earned 920 total points
ID: 12233012
The format will go something such as the below...

(START)
-----------------------------7d428027f101d8
Content-Disposition: form-data; name="File1"; filename="c:\myfile.txt"
Content-Type: text/plain

myfile.txt's data
-----------------------------7d428027f101d8
Content-Disposition: form-data; name="firstname"

gerald
-----------------------------7d428027f101d8--
(END)


This is not a regular method for form values being submitted so the ASP script will have to parse for both the file-data and the input values.
0
 
LVL 17

Expert Comment

by:zzzzzooc
ID: 12537833
ping
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month12 days, 7 hours left to enroll

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question