Malharhak Posted November 14, 2012 Posted November 14, 2012 (edited) Hi, i used this fonction on following topic : All works perfect, but how can i know file upload percent progression ? Edited February 22, 2023 by Malharhak
FireFox Posted November 14, 2012 Posted November 14, 2012 @Malharhak You can't get the percentage with the function given in the UDF in so far as it sends all your data at once. You need to split the data you want to send (e.g: by 1024 bytes), then make a while until you have finished to send your data. In this while you can update the percentage of the data sent. Br, FireFox.
Malharhak Posted November 14, 2012 Author Posted November 14, 2012 (edited) Thanks for anwser. Edited February 22, 2023 by Malharhak
FireFox Posted November 14, 2012 Posted November 14, 2012 You can do like this : Func _HTTPPost($host, $page, $socket = -1, $data = "") Local $command If $socket == -1 Then If $_HTTPLastSocket == -1 Then Return SetError(1) EndIf $socket = $_HTTPLastSocket EndIf Local $datasize = StringLen($data) $command = "POST " & $page & " HTTP/1.1" & @CRLF $command &= "Host: " & $host & @CRLF $command &= "User-Agent: " & $_HTTPUserAgent & @CRLF $command &= "Connection: close" & @CRLF $command &= "Content-Type: application/x-www-form-urlencoded" & @CRLF $command &= "Content-Length: " & $datasize & @CRLF $command &= "" & @CRLF TCPSend($socket, $command) Local $bytessent = 0 While $bytessent < $datasize $bytessent += TCPSend($socket, StringMid($data, 1 + $bytessent, 1024)) ;1+ :stringmid starts at 1 WEnd TCPSend($socket, @CRLF) If $bytessent == 0 Then Return SetError(2, @error, 0) EndIf Return SetError(0, 0, $bytessent) EndFunc ;==>_HTTPPost The best would to use winapi functions to read the file at X offset; because you want to send the data of a file, right? Br, FireFox.
Malharhak Posted November 14, 2012 Author Posted November 14, 2012 (edited) On 11/14/2012 at 11:24 AM, 'FireFox said: You can do like this : Func _HTTPPost($host, $page, $socket = -1, $data = "") Local $command If $socket == -1 Then If $_HTTPLastSocket == -1 Then Return SetError(1) EndIf $socket = $_HTTPLastSocket EndIf Local $datasize = StringLen($data) $command = "POST " & $page & " HTTP/1.1" & @CRLF $command &= "Host: " & $host & @CRLF $command &= "User-Agent: " & $_HTTPUserAgent & @CRLF $command &= "Connection: close" & @CRLF $command &= "Content-Type: application/x-www-form-urlencoded" & @CRLF $command &= "Content-Length: " & $datasize & @CRLF $command &= "" & @CRLF TCPSend($socket, $command) Local $bytessent = 0 While $bytessent < $datasize $bytessent += TCPSend($socket, StringMid($data, 1 + $bytessent, 1024)) ;1+ :stringmid starts at 1 WEnd TCPSend($socket, @CRLF) If $bytessent == 0 Then Return SetError(2, @error, 0) EndIf Return SetError(0, 0, $bytessent) EndFunc ;==>_HTTPPost The best would to use winapi functions to read the file at X offset; because you want to send the data of a file, right? Br, FireFox. Edited February 22, 2023 by Malharhak
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