Login  
Search All Forums
Dart Home | PowerTCP Web for ActiveX | Custom Development Reply | PowerTCP Web for ActiveX Topics | Forums   
AuthorForum: PowerTCP Web for ActiveX
Topic: Posting File to PHP
shawnfunn

From: none, AL USA
Posts: 2
Member Since: 08/06/03
posted August 6, 2003 2:39 AM

I posted this file with IE and it works fine but when I use the DartWeb the file won't save and it wont go through. Do you guys have any info on why it doesnt work? The PHP knows its a file upload of JPEG but the content of the file isnt getting through.


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 = ApplicationPath() & "snapshot.jpg"
l = stream.Read(s)

'Add Values and Names
value.Add s
name.Add "sourcefile"

' 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: image/jpeg" & vbCrLf & vbCrLf
 postString = postString & value(x) & vbCrLf
Next x
postString = postString & boundary & "--" & vbCrLf

' Post
HTTPControl.URL = "http://www.myurl.com/new/server.php?pictype=profile&check=1"

HTTPControl.Post postString, reqH, result, respH
K M Drake



From: Utica, NY USA
Posts: 3406
Member Since: 07/14/00
posted August 6, 2003 11:44 AM

Hi,
Does replacing:
postString = postString & boundary & vbCrLf
with
postString = postString & "--" & boundary & vbCrLf
work ok?

It is required for each boundary to start with the two dashes. I have modified the forum post where I suspect you got this code to reflect this.
Thanks,
-ken
shawnfunn

From: none, AL USA
Posts: 2
Member Since: 08/06/03
posted August 6, 2003 5:28 PM

Worked perfectly. Thanks a lot.
Reply | PowerTCP Web for ActiveX Topics | Forums   
This site is powered by PowerTCP WebServer Tool PowerTCP WebServer for ActiveX