Bonjour, je cherche actuellement un script pour envoyer une image sur l'hébergeur
http://s4.noelshack.com/#non-flash
Le seul script que j'ai réussi a faire, est de d'abord l'envoyer sur imageshack, puis la transférer sur NoelShack, pas rapide du tout donc ! :
► Afficher le texte
Code : Tout sélectionner
$llien = Inputbox("lien", entrerz le lien de l'image :")
$liendelimagenoelshack : UploadNoelShack($llien)
Func UploadNoelShack($Message)
$noeshacknormal = "http://noelshack.com/"
$oIE = _IECreate ($noeshacknormal,0,0,1,1)
_IELoadWait($oIE)
$noelshack = $oIE.LocationURL
InetGet($noelshack&"ajaxtunnel.php?action=uploadURL&url="&$Message, "dlnoel.php")
Sleep(500)
$longlink = FileRead("dlnoel.php")
$longlink = StringTrimLeft($longlink, 10)
$longlink = StringSplit($longlink, '"')
$shortlink = $longlink[1]
$imgurl = $noelshack&$shortlink
If $imgurl = $noelshack Then
MsgBox(48, "Erreur", "L'envois vers NoelShack a échoué, l'image va etre transferé sur ImageShack")
$imgurl = $Message
EndIf
Sleep(100)
FileDelete("dlnoel.php")
Return $imgurl
_IEQuit($oIE)
EndFunc
J'ai aussi essayer via la méthode post :
► Afficher le texte
Code : Tout sélectionner
$lienimg = _UploadTo_noelshack("test.jpg")
InputBox("lien", "lien :", $lienimg)
Func _UploadTo_noelshack($sFile, $iRet_Type = 0)
$sLocalFile = $sFile ;Local file
$sHost = 's4.noelshack.com' ;Upload page addresss
$sFormAction = '?old' ;Upload form action ("form action=...upload.php)"
$sFormName = 'fichier' ;Upload form name ("input name=uploadfile")
$sResponse = _TCPFileUpload($sLocalFile, $sHost, $sFormAction, $sFormName)
;$sResponse = StringSplit($sResponse, "]")
;$liennoelshack = $sResponse[7]
;$liennoelshack = StringReplace($liennoelshack, "[/img", "")
;$liennoelshack = StringReplace($liennoelshack, "thumbs", "images")
$liennoelshack = $sResponse
Return $liennoelshack
EndFunc
Func _TCPFileUpload($sLocalFile, $sHost, $sFormAction, $sFormName)
Local $sFileRead, $sFileType, $sBoundary, $sData, $iDataSize, $sHeader, $sCommand, $iSocket, $sRecv
$sHost = StringRegExpReplace($sHost, '(?i)^https?://', '')
$sFileRead = FileRead($sLocalFile)
$sFileType = StringRegExpReplace($sLocalFile, '^.*\.', '')
If $sFileType = 'jpg' Then $sFileType = 'jpeg'
$sBoundary = StringFormat('----------------%s%s%smzF', @MIN, @HOUR, @SEC)
$sData = '--' & $sBoundary & @CRLF & _
'Content-Disposition: form-data; name="' & $sFormName & '"; filename="' & StringRegExpReplace($sLocalFile, '^.*\\', '') & '"' & @CRLF & _
'Content-Type: image/' & $sFileType & @CRLF & @CRLF & _
$sFileRead & @CRLF & '--' & $sBoundary & '--' & @CRLF
$iDataSize = StringLen($sData)
$sHeader = 'POST ' & $sFormAction & ' HTTP/1.1' & @CRLF & _
'Host: ' & $sHost & @CRLF & _
'Connection: close' & @CRLF & _
'Content-Type: multipart/form-data; boundary=' & $sBoundary & @CRLF & _
'Content-Length: ' & $iDataSize & @CRLF & @CRLF
$sCommand = $sHeader & $sData
TCPStartup()
$iSocket = TCPConnect(TCPNameToIP($sHost), 80)
TCPSend($iSocket, $sCommand)
While 1
$sRecv &= TCPRecv($iSocket, 20000)
If StringLen($sRecv) <> 0 Then ExitLoop
Sleep(50)
WEnd
TCPShutdown()
Return $sRecv
EndFunc
Mais ca me retourne comme code :
► Afficher le texte
Code : Tout sélectionner
<html>
<head><title>400 Bad Request</title></head>
<body bgcolor="white">
<center><h1>400 Bad Request</h1></center>
<hr><center>nginx/1.0.11</center>
</body>
</html>
Donc la j'essaye en simulant une navigation internet :
► Afficher le texte
Code : Tout sélectionner
$var = FileOpenDialog("Choose a Picture", "C:Temp", "Images (*.jpg;*.jpeg;*.png;*.gif;*.bmp;*.tif;*.tiff)", 1 + 4)
$oIE = _IECreate ("http://s4.noelshack.com/#non-flash",0,0,1,1)
_IELoadWait($oIE)
$adressefichier = _IEGetObjById($oIE, "fichier")
_IEAction($adressefichier, "focus")
_IEDocInsertText($adressefichier, $var)
$submit_Name = _IEGetObjByName($oIE, "submit")
_IEAction($submit_Name, "Click")
_IELoadWait($oIE)
Sleep(4000)
InputBox("lien","lien", $oIE.LocationURL)
_IEQuit($oIE)
Mais j'ai l'erreur :
Code : Tout sélectionner
--> IE.au3 V2.4-0 Error from function _IEDocInsertText, $_IEStatus_InvalidObjectType (Expected document element)
Voila j'ai plus d'idée comment faire ?
Merci.