C'est bon !
J'ai trouvé en sniffant simplement ce qui passait et en faisant un tour sur la RFC 1867.
Voici une fonction un peu bourrin qui ne prend qu'un fichier en compte, mais ca peux bien dépanner :
Code : Tout sélectionner
Func HTTPFILE($site, $page, $fileContent, $mimetype, $varName="fichier", $filename="fichier")
TCPStartup()
Local Const $IP = TCPNameToIP($site)
Local Const $SOCKET = TCPConnect($IP, 80)
If $fileContent <> -1 Then
;~ Devrait être généré aléatoirement
$bundary = '17992491914241'
$fileContent = '-----------------------------' & $bundary & @CRLF & 'Content-Disposition: form-data; name="' & $varName & '"; filename="' & $filename & '"' & @CRLF & 'Content-Type: ' & $mimetype & @CRLF & @CRLF & $fileContent & @CRLF & "-----------------------------' & $bundary & '--" & @CRLF
TCPSend($SOCKET, "POST " & $page & " HTTP/1.0" & @CRLF & _
"Host: " & $site & @CRLF & _
"Content-Type: multipart/form-data; boundary=---------------------------" & $bundary & @CRLF & _
"Content-Length: " & StringLen($fileContent) & @CRLF & _
@CRLF & _
$fileContent)
Else
TCPSend($SOCKET, "GET " & $page & " HTTP/1.0" & @CRLF & _
"HOST: " & $site & @CRLF & @CRLF)
EndIf
Local $recv
Do
$recv &= TCPRecv($SOCKET, 1024)
Until @error
TCPShutdown()
Return $recv
EndFunc
Et pi un truc comme ca pour l'appeler (exemple pour un jpg) :
Code : Tout sélectionner
$file = FileOpen($img_file, 0)
If $file <> -1 Then
$content = FileRead($file)
MsgBox(64, "", HTTPFILE("www.mon-site.net", "/photos.php?mode=add", $content, "image/jpeg", "fichier", "toto.jpg"))
EndIf
Allez, à la prochaine galère AutoItienne !!