#include <Array.au3>
$sFile = @SystemDir & "\oobe\images\merlin.gif"
_UploadToImageShack_Example($sFile)
_UploadToTurboUpload_Example($sFile)
Func _UploadToImageShack_Example($sFile, $iRet_Type = 0)
Local $Ret = DllCall(@ScriptDir & "\UploadFile.dll", _
"str", "UploadFile", _
"str", "http://www.imageshack.us/upload_api.php", _ ;Action
"str", "fileupload", _ ;Form Name
"str", "image/" & StringRight($sFile, 3), _ ;Content-Type
"str", $sFile) ;File path
If @error Then Return SetError(1)
Local $aRet[4] = _
[ _
StringRegExpReplace($Ret[0], '(?is).*<(image_link)>(.*?)</\1>.*', '\2'), _
StringRegExpReplace($Ret[0], '(?is).*<(image_html)>(.*?)</\1>.*', '\2'), _
StringRegExpReplace($Ret[0], '(?is).*<(image_bb)>(.*?)</\1>.*', '\2'), _
StringRegExpReplace($Ret[0], '(?is).*<(image_bb2)>(.*?)</\1>.*', '\2') _
]
_ArrayDisplay($aRet)
If $iRet_Type < 0 Or $iRet_Type > 3 Then $iRet_Type = 0
InputBox('Result - _UploadToImageShack', 'Show the image?', $aRet[$iRet_Type])
If Not @error Then ShellExecute($Ret)
EndFunc
Func _UploadToTurboUpload_Example($sFile)
Local $Ret = DllCall(@ScriptDir & "\UploadFile.dll", _
"str", "UploadFile", _
"str", "http://s2.turboupload.com/cgi-bin/upload.cgi?upload_id=", _ ;Action
"str", "file", _ ;Form Name
"str", "image/" & StringRight($sFile, 3), _ ;Content-Type
"str", $sFile) ;File path
If @error Then Return SetError(1)
Local $Tmp_File = @TempDir & '\~TurboUpload_Link.tmp'
Local $Location = StringStripWS(StringRegExpReplace($Ret[0], '(?is).*?Location: (.*?)\r\n.*?', '\1'), 3)
InetGet($Location, $Tmp_File, 1, 0)
$Ret = FileRead($Tmp_File)
FileDelete($Tmp_File)
$Ret = StringRegExpReplace($Ret, '(?is).*Direct Link:</b></td><td><input id=.*?value="(.*?)"></td><td>.*', '\1')
InputBox('Result - _UploadToTurboUpload', 'Show the image?', $Ret)
If Not @error Then ShellExecute($Ret)
EndFunc