Tim Net Posted December 8, 2008 Share Posted December 8, 2008 I've tried several ways of using TCPSend to do a HTTP FORM UPLOAD and have been unsuccessful. Does anyone have a UDF or working example of doing this? One of the problems is that I am not sure how exactly to calculate the Content-Length. Thanks in advance. Tim Link to comment Share on other sites More sharing options...
ProgAndy Posted December 8, 2008 Share Posted December 8, 2008 Here i made an example with WinHTTP-UDF: http://www.autoitscript.com/forum/index.ph...st&p=610967(started with TCPSend, changed to WinHTTP.)the TCP functions can be found here: http://www.autoit.de/index.php?page=Thread&threadID=6555 *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes Link to comment Share on other sites More sharing options...
Tim Net Posted December 8, 2008 Author Share Posted December 8, 2008 Here's the code of what I think should work: $line_1 = "POST /Capture/do.asp HTTP/1.1" $line_2 = "Host: www.domain.com" $line_3 = "Accept: */*" $line_4 = "Content-Length: " $line_5 = "Content-Type: multipart/form-data; boundary=----------------------------ef2347b648ea" $line_6 = "------------------------------ef2347b648ea" $line_7 = 'Content-Disposition: form-data; name="stuff"; filename="stuff.txt"' $line_8 = "Content-Type: text/plain" $stuff = Fileopen( @ScriptDir & "\stuff.txt", 0) $data = FileRead($stuff) $line_9 = "------------------------------ef2347b648ea" $content_length = stringlen($line_6) + stringlen($line_7) + stringlen($line_8) + stringlen($data); + stringlen($line_9) $line_4 = $line_4 & $content_length TCPStartup() $connection = TCPConnect("192.122.12.3",80) tcpsend($connection ,$line_1 & @crlf) tcpsend($connection ,$line_2 & @crlf) tcpsend($connection ,$line_3 & @crlf) tcpsend($connection ,$line_4 & @crlf) tcpsend($connection ,$line_5 & @crlf) tcpsend($connection ,@crlf) tcpsend($connection ,$line_6 & @crlf) tcpsend($connection ,@crlf) tcpsend($connection ,$line_7 & @crlf) tcpsend($connection ,$line_8 & @crlf) tcpsend($connection ,@crlf ) tcpsend($connection ,$data) tcpsend($connection ,@crlf) tcpsend($connection ,$line_9 & @crlf) tcpsend($connection ,@crlf) TCPShutdown() Exit Link to comment Share on other sites More sharing options...
trancexx Posted December 14, 2008 Share Posted December 14, 2008 Here's the code of what I think should work: $line_1 = "POST /Capture/do.asp HTTP/1.1" $line_2 = "Host: www.domain.com" $line_3 = "Accept: */*" $line_4 = "Content-Length: " $line_5 = "Content-Type: multipart/form-data; boundary=----------------------------ef2347b648ea" $line_6 = "------------------------------ef2347b648ea" $line_7 = 'Content-Disposition: form-data; name="stuff"; filename="stuff.txt"' $line_8 = "Content-Type: text/plain" $stuff = Fileopen( @ScriptDir & "\stuff.txt", 0) $data = FileRead($stuff) $line_9 = "------------------------------ef2347b648ea" $content_length = stringlen($line_6) + stringlen($line_7) + stringlen($line_8) + stringlen($data); + stringlen($line_9) $line_4 = $line_4 & $content_length TCPStartup() $connection = TCPConnect("192.122.12.3",80) tcpsend($connection ,$line_1 & @crlf) tcpsend($connection ,$line_2 & @crlf) tcpsend($connection ,$line_3 & @crlf) tcpsend($connection ,$line_4 & @crlf) tcpsend($connection ,$line_5 & @crlf) tcpsend($connection ,@crlf) tcpsend($connection ,$line_6 & @crlf) tcpsend($connection ,@crlf) tcpsend($connection ,$line_7 & @crlf) tcpsend($connection ,$line_8 & @crlf) tcpsend($connection ,@crlf ) tcpsend($connection ,$data) tcpsend($connection ,@crlf) tcpsend($connection ,$line_9 & @crlf) tcpsend($connection ,@crlf) TCPShutdown() ExitCheck sent before TCPShutdown() - you lack time ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
Developers Jos Posted December 14, 2008 Developers Share Posted December 14, 2008 moved to correct forum SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now