MrCreatoR Posted February 14, 2008 Share Posted February 14, 2008 Hi,I am trying to upload an image from my hard drive to some service, for example to imageshack.us.And i using this method:$File = 'c:\test.png' $oWinHttpRequest = ObjCreate("WinHttp.WinHttpRequest.5.1") $oWinHttpRequest.Open("PUT", "http://www.imageshack.us/index.php", False) $oWinHttpRequest.Send($File) $hFile = FileOpen("Response.htm", 2) FileWrite($hFile, $oWinHttpRequest.ResponseText) FileClose($hFile) ShellExecute("Response.htm")oÝ÷ ضzÊhÇ¡¶jZèZ½ç«®ìjwb¨«'¢Û©yÕ)º¹p¢¹,jëh×6$File = 'c:\test.png' $URL = 'http://creator-lab.ucoz.ru/Images/Image_2.png' $oWinHttpRequest = ObjCreate("WinHttp.WinHttpRequest.5.1") $oWinHttpRequest.Open("PUT", "http://www.imageshack.us/transload.php?uploadtype=on&fileupload=&url=" & $URL, False) $oWinHttpRequest.Send('')But i need to upload image from localhost (from my hard drive).What do i miss here? Spoiler Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1 AutoIt Russian Community My Work... Spoiler Projects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating ) * === My topics === * ================================================== ================================================== AutoIt is simple, subtle, elegant. © AutoIt Team Link to comment Share on other sites More sharing options...
evilertoaster Posted February 14, 2008 Share Posted February 14, 2008 Some related reading here if you havn't seen it already-http://www.autoitscript.com/forum/index.php?showtopic=49874http://www.autoitscript.com/forum/index.php?showtopic=32580But the issue could simply be that the web server has disabled 'put' requests of that form...Have you tried simply scripting the file upload form they provide? Link to comment Share on other sites More sharing options...
MrCreatoR Posted February 14, 2008 Author Share Posted February 14, 2008 Have you tried simply scripting the file upload form they provide?I am not sure if understand this one....And thanks for the links, usefull stuff i found there, but i thought that maybe there will be a more simple way to upload, without using IE function, or other external (and extrim ) resources. Spoiler Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1 AutoIt Russian Community My Work... Spoiler Projects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating ) * === My topics === * ================================================== ================================================== AutoIt is simple, subtle, elegant. © AutoIt Team Link to comment Share on other sites More sharing options...
MrCreatoR Posted February 14, 2008 Author Share Posted February 14, 2008 (edited) Even with the _IE funcs i have difficulties to upload ..How to set file path to the input?#include <IE.au3> $File = 'c:\test.png' _IEErrorHandlerRegister("__IE_Err_Handler") ;_IEErrorNotify(0) $oIE = _IECreate("http://www.imageshack.us") $oForm = _IEFormGetCollection($oIE, 0) $oQuery = _IEFormElementGetCollection($oForm, 1) _IEFormElementSetValue($oQuery, $File) _IEFormSubmit($oForm) Func __IE_Err_Handler() SetError(1) EndFuncIf i use 0 in $oQuery = _IEFormElementGetCollection($oForm, 1), then the path is inserted to search input. But how to insert in the next input? it seems to be simple, but i am probably very tired P.SI also know that the input id/name is «fileupload». But how to use it? Edited February 14, 2008 by MsCreatoR Spoiler Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1 AutoIt Russian Community My Work... Spoiler Projects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating ) * === My topics === * ================================================== ================================================== AutoIt is simple, subtle, elegant. © AutoIt Team Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted February 14, 2008 Moderators Share Posted February 14, 2008 Here's an example from the snippet database. Link to comment Share on other sites More sharing options...
MrCreatoR Posted February 14, 2008 Author Share Posted February 14, 2008 Here's an example from the snippet database.Thanks! But it's not working for me - This what i get to console: --> IE.au3 V2.3-1 Warning from function _IEFormElementGetObjByName, $_IEStatus_NoMatch --> IE.au3 V2.3-1 Error from function _IEAction, $_IEStatus_InvalidDataType paste image url here 0 0 The problem is with focus, the input not getting the focus, therefore path not sended to the input. Spoiler Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1 AutoIt Russian Community My Work... Spoiler Projects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating ) * === My topics === * ================================================== ================================================== AutoIt is simple, subtle, elegant. © AutoIt Team Link to comment Share on other sites More sharing options...
MrCreatoR Posted February 14, 2008 Author Share Posted February 14, 2008 Ok, here is a workaround, very not preferable Func _Uploadpicture($sPath) _IEErrorNotify(0) _IEErrorHandlerRegister() $oIE = _IECreate("http://imageshack.us", 0, 0, 1, 0) $hwnd = _IEPropertyGet($oIE, "hwnd") $oForm = _IEFormGetCollection($oIE, 1) $oButton = _IEGetObjByName($oForm, "butan") $oFile = _IEFormElementGetObjByName($oForm, "fileupload") ControlFocus($hwnd, "", "Internet Explorer_Server1") ControlSend($hwnd, "", "Internet Explorer_Server1", "{TAB 28}") ControlSend($hwnd, "", "Internet Explorer_Server1", $sPath) _IEAction($oButton, "Click") _IELoadWait($oIE, 500, 60000) $oInputs = _IETagNameGetCollection($oIE, "INPUT") For $oInput In $oInputs If String($oInput.Type) = "text" And String($oInput.Name) <> "q" Then ConsoleWrite($oInput.Value & @CRLF) EndIf Next _IEErrorHandlerDeRegister() _IEQuit($oIE) EndFunc As you can see, i need it hidden, but there is Click sound when submit, and the active window is unactivated, even if i use 0 as last paramter in _IECreate function. Is there maybe some Dll available, so i can use it something like this: $aRet = DllCall(@TempDir & "\UploadFile.dll", _ "str", "UploadFile", _;Func Name "str", "http://www.imageshack.us/index.php", _;Action "str", "fileupload", _;Form Name "str", "image/png", _;Content-Type "str", $sImageFile);File Path And the $aRet[0] will have the source submited. I searched google, but really didn't find anything usefull . Spoiler Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1 AutoIt Russian Community My Work... Spoiler Projects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating ) * === My topics === * ================================================== ================================================== AutoIt is simple, subtle, elegant. © AutoIt Team Link to comment Share on other sites More sharing options...
sl4y3r Posted November 8, 2010 Share Posted November 8, 2010 I've found a dll @http://www.torry.net/vcl/internet/http/ImageShackUp10011.zip But i've no time to write an udf now... can somebody do it for me/us? greetz Link to comment Share on other sites More sharing options...
MrCreatoR Posted July 24, 2011 Author Share Posted July 24, 2011 (edited) 3 years later, and here is the solution (on pure AutoIt i must say), i knew i find it eventualy expandcollapse popup#include <Array.au3> $sFile = @SystemDir & '\oobe\images\merlin.gif' ;On WinXP _UploadTo_Imageshack($sFile) _UploadTo_Turboupload($sFile) Func _UploadTo_Imageshack($sFile, $iRet_Type = 0) $sLocalFile = $sFile ;Local file $sHost = 'http://imageshack.us' ;Upload page addresss $sFormAction = '/upload_api.php' ;Upload form action ("form action=...upload.php)" $sFormName = 'fileupload' ;Upload form name ("input name=uploadfile") $sResponse = _TCPFileUpload($sLocalFile, $sHost, $sFormAction, $sFormName) Local $aRet[4] = _ [ _ StringRegExpReplace($sResponse, '(?is).*<(image_link)>(.*?)</\1>.*', '\2'), _ StringRegExpReplace($sResponse, '(?is).*<(image_html)>(.*?)</\1>.*', '\2'), _ StringRegExpReplace($sResponse, '(?is).*<(image_bb)>(.*?)</\1>.*', '\2'), _ StringRegExpReplace($sResponse, '(?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($aRet[$iRet_Type]) EndFunc Func _UploadTo_Turboupload($sFile) $sLocalFile = $sFile ;Local file $sHost = 'http://turboupload.com' ;Upload page addresss $sFormAction = '/cgi-bin/upload.cgi?upload_id=' ;Upload form action ("form action=...upload.php)" $sFormName = 'file_1' ;Upload form name ("input name=uploadfile") $sResponse = _TCPFileUpload($sLocalFile, $sHost, $sFormAction, $sFormName) $sLocation = StringRegExpReplace($sResponse, '(?is).*?Location: ([^\r\n]*)\r\n.*', '\1') $sResponse = BinaryToString(InetRead($sLocation, 1)) $sResponse = StringRegExpReplace($sResponse, '(?is).*<h2>Code for forums</h2>\s*<textarea [^\r\n]*>([^\r\n]*)</textarea>.*', '\1') ConsoleWrite($sResponse & @LF) 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 EndFuncThanks to Redline from AutoIt Russian Community forum. Edited July 24, 2011 by MrCreatoR Spoiler Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1 AutoIt Russian Community My Work... Spoiler Projects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating ) * === My topics === * ================================================== ================================================== AutoIt is simple, subtle, elegant. © AutoIt Team Link to comment Share on other sites More sharing options...
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