Jump to content

IE fileuploader


liu
 Share

Recommended Posts

I have written a autoit script that can upload a file from pc, however it seems not work, following is my code:

$objIE = objCreate("InternetExplorer.Application") 

$objIE.Navigate("webpage address")

    While $objIE.Busy 

        sleep(1000)

    wend

    While $objIE.ReadyState <> 4 

        sleep(500)

    wend



    With $objIE.document.forms("name of the form")

       .ctl00_MainContentPlaceHolder_Region1_Uploader_FileUploader.value = "C:\autotest.CAB"

       .ctl00_MainContentPlaceHolder_UploadButton.click

      EndWith

For some reason I have to use the createobject function instead of using IE.au3 functions. Can any one tell me how to make it work? Thanks a lot! :P

Link to comment
Share on other sites

Yes you can use IE.au3 the function for it are

#include <IE.au3>

$oIE = _IECreate("Webpage Address")
_IELoadWait($oIE)

$oForm = _IEFormGetObjByName($oIE, "Name of the Form")
$oUpload = _IEFormGetObjByName($oIE, "ctl00_MainContentPlaceHolder_UploadButton")
$oQuery = _IEFormElementGetObjByName($oForm, "ctl00_MainContentPlaceHolder_Region1_Uploader_FileUploader")
_IEFormElementSetValue($oQuery, "C:\autotest.CAB")
_IEAction($oUpload, "click")

Contact via MSN: [email=terarink_msn@hotmail.com]terarink_msn@hotmail.com[/email], yahoo: terarink_yah

Link to comment
Share on other sites

I have tried that but there seems to be some errors and somehow it does not work, the code I use is as follows:

#include <IE.au3>
$objIE = objCreate("InternetExplorer.Application.1")
 $objIE.Navigate("web page address")
$oForm2 = _IEFormGetObjByName($objIE, "aspnetForm")
$oUpload = _IEFormGetObjByName($objIE, "ctl00_MainContentPlaceHolder_UploadButton")
$oQuery = _IEFormElementGetObjByName($oForm2,
"ctl00_MainContentPlaceHolder_Region1_Uploader_FileUploader")
_IEFormElementSetValue($oQuery, "C:\RM_x32.CAB")
_IEAction($oUpload, "click")

the error message is

--> IE.au3 V2.3-1 Warning from function _IEFormGetObjByName, $_IEStatus_NoMatch

--> IE.au3 V2.3-1 Error from function _IEFormElementSetValue, $_IEStatus_InvalidObjectType (Browser securuty prevents SetValue of TYPE=FILE)

--> IE.au3 V2.3-1 Error from function _IEAction, $_IEStatus_InvalidDataType

I don't know why it says this :P

Link to comment
Share on other sites

Read the remarks for _IEFormElementSetValue in the helpfile.

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...