| Dart Home | PowerTCP Web for ActiveX | Custom Development | Reply | PowerTCP Web for ActiveX Topics | Forums |
| Author | Forum: PowerTCP Web for ActiveX Topic: Post Form with ENCTYPE |
| User987 Posts: 1 Member Since: 12/28/00 |
posted December 28, 2000 7:34 PM I have an ASP page that does a file upload. I need to access this page from my VB6 program. When I try to do so, I keep getting this error: Invalid data format. You must include ENCTYPE="multipart/form-data" in your FORM. I cannot find how to add the ENCTYPE anywhere in the doc. or on the site. The ASP page uses SAFileUpload. I've also tried it with ASPUpload. Any help is appreciated. Thanks, Stuart |
Tony Priest![]() From: Utica, NY USA Posts: 8466 Member Since: 04/11/00 |
posted December 28, 2000 7:49 PM You probably need to add some header lines. See the Request Headers param for the Get method. The sample VB app also shows how to add headers. |
K M Drake![]() From: Utica, NY USA Posts: 3406 Member Since: 07/14/00 |
posted December 29, 2000 9:01 AM Below is a project I have used to do multipart posts. It is the only way I have found to do it with the control. Be advised that you need to have a dll which allows ASP uploads, which you indicate you have. Option Explicit Const URL = "" Private Sub Command1_Click() Dim result As String Dim postString As String Dim reqH As New DartStrings Dim respH As New DartStrings Dim value As New DartStrings Dim name As New DartStrings Dim x As Integer Dim boundary As String ' Add Multipart Header boundary = "-----------------------------7d02e53b03d8" reqH.Add "Content-Type: multipart/form-data; boundary=" & boundary & vbCrLf ' Add Field Values and Names value.Add "This is item 1" value.Add "This is item 2" name.Add "Item1" name.Add "Item2" ' Create PostString postString = "" For x = 1 To name.Count postString = postString & "--" & boundary & vbCrLf postString = postString & "Content-Disposition: form-data; name=""" & name(x) & "" & vbCrLf & vbCrLf postString = postString & value(x) & vbCrLf Next x postString = postString & boundary & "--" & vbCrLf ' Post Http1.URL = URL Http1.Post postString, reqH, result, respH End Sub |
K M Drake![]() From: Utica, NY USA Posts: 3406 Member Since: 07/14/00 |
posted January 2, 2001 4:35 PM Here is code demonstrating multipart file upload (the previous post shows multipart post of a string): Option Explicit Const URL = "" Const FILE = "" Private Sub Command1_Click() Dim result As String Dim postString As String Dim reqH As New DartStrings Dim respH As New DartStrings Dim value As New DartStrings Dim name As New DartStrings Dim x As Integer Dim boundary As String ' Add Multipart Header boundary = "-----------------------------7d02e53b03d8" reqH.Add "Content-Type: multipart/form-data; boundary=" & boundary & vbCrLf ' Read File as Stream Dim s As String Dim stream As New DartStream Dim l As Long stream.FileMode = createExisting stream.FileName = FILE l = stream.Read(s) 'Add Values and Names value.Add s name.Add "FILE1" ' Create PostString postString = "" For x = 1 To name.Count postString = postString & "--" & boundary & vbCrLf postString = postString & "Content-Disposition: form-data; name=""" & name(x) & """" & "; filename=""" & stream.FileName & """" & vbCrLf postString = postString & "Content-type: text/plain" & vbCrLf & vbCrLf postString = postString & value(x) & vbCrLf Next x postString = postString & boundary & "--" & vbCrLf ' Post Http1.URL = URL Http1.Post postString, reqH, result, respH End Sub |
| User592 Posts: 8 Member Since: 06/29/01 |
posted June 29, 2001 1:13 PM Do you have an example of how to do a post with a string and a post with one or more files in Delphi? Everything I've seen so far seems to be VB. Thanks in advance. |
K M Drake![]() From: Utica, NY USA Posts: 3406 Member Since: 07/14/00 |
posted June 29, 2001 1:28 PM Sorry, we do not. The key is to build the string you are posting into the correct format, as demonstrated in this thread. If you are interested in a custom sample, we may be able to put something together for you (please contact our sales department). Another option is to use the Web Enterprise Tool, which makes the posting of files a breeze. -ken |
| User200 Posts: 23 Member Since: 09/09/01 |
posted October 21, 2001 10:20 AM What about binary files? I see in the Documentation that the first argument to Post can be either a string or byte array, so I am assuming for binary files "postString" from the example would be replaced by a Byte array and the stream would read bytes into it. But the documentation (below) mentions "Specifies the source file name," ??? please explain or show an example and the referenced example but for binary files would be appreciated as well. Data String or Byte array. Specifies the source file name, or a String or Byte array that contains data to be sent to the server. |
K M Drake![]() From: Utica, NY USA Posts: 3406 Member Since: 07/14/00 |
posted October 22, 2001 11:52 AM Hi, The VB code here: http://support.dart.com/forum.dwp?view=2310#FID2310 works with binary files as well. -ken K M Drake Dart Tech Support |
| User200 Posts: 23 Member Since: 09/09/01 |
posted October 22, 2001 2:19 PM Yes, I accidentally found that out earlier this morning so I am in business. I am still curious though that the documentation mentions a filename as the first argument to Post() what does that mean? |
K M Drake![]() From: Utica, NY USA Posts: 3406 Member Since: 07/14/00 |
posted October 22, 2001 2:44 PM Hi, That is for Posting the contents of a file, which is different than uploading a file. -ken K M Drake Dart Tech Support |
| Reply | PowerTCP Web for ActiveX Topics | Forums |
This site is powered by
PowerTCP WebServer for ActiveX
|