Sign in to follow this  
Followers 0
Malharhak

Show file upload percent progression (_HTTPPost_File() function)

5 posts in this topic

Hi, i used this fonction on following topic :

All work perfect, but how can i know file upload percent progression ?

Thank's for helping :)

Tips : I attached HTTP.au3 source.

HTTP.au3

Share this post


Link to post
Share on other sites



@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.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

Thank's for anwser. :)

Can you tell me how split data with this function ?

Thank's for helping ...

Share this post


Link to post
Share on other sites

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.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

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.

Yep, you right.

thank's for help, i will test this soon !

Work perfect, thank's you ! :)

Edited by Malharhak

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0