zhao Posted May 3, 2007 Posted May 3, 2007 the html code: <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" id="myopera-theme12" xml:lang="en"> <head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>Files</title><link rel="stylesheet" type="text/css" href="/community/css/users/files_big_white.css" media="all" /></head> <body id="myopera"> <div><form id="fileform" action="/netpand/files/addpic.pl" method="post" enctype="multipart/form-data"> <div><p>1. Select into which directory you wish to upload the file.</p> <input type="radio" name="dir" id="dir_/files" value="/files" /> <label for="dir_/files">/files</label><br /><p style="margin-left:.5em">? <a href="dircreation.dml">Create a new directory</a></p> <p>2. Select a file that you want to upload.</p> <input type="file" name="file" id="file" /><p>3. Click 'upload file'.</p> <input type="submit" value=" UPLOAD " class="submit" id="submit" /></div> </form></div></body></html> my code: #include <IE.au3> $path = "example.html" $oIE = _IECreate (path) $oForm = _IEFormGetCollection ($oIE,0) $oQuery = _IEFormElementGetObjByName ($oForm, "file") _IEFormElementSetValue ($oQuery, "AutoIt IE.au3") but it returns:"--> IE.au3 Error from function _IEFormElementSetValue, $_IEStatus_InvalidObjectType (Browser securuty prevents SetValue of TYPE=FILE)" is there any solution?
Moderators big_daddy Posted May 3, 2007 Moderators Posted May 3, 2007 There is an example in the help file of how to accomplish this (_IEFormElementSetValue). I use a slightly modified version of that one. ; ******************************************************* ; Example 4 - Set the value of an INPUT TYPE=FILE element ; (security restrictions prevent using _IEFormElementSetValue) ; ******************************************************* ; #include <IE.au3> $oIE = _IE_Example("form") $hwnd = _IEPropertyGet($oIE, "hwnd") $oForm = _IEFormGetObjByName($oIE, "ExampleForm") $oInputFile = _IEFormElementGetObjByName($oForm, "fileExample") ; Assign input focus to the field and then send the text string _IEAction($oInputFile, "focus") Sleep(250) ControlSend($hwnd, "", "Internet Explorer_Server1", "C:\myfile.txt")
Ivan2 Posted October 16, 2010 Posted October 16, 2010 (edited) Please, answer me guys. I use the WebBrowser conrol in my VB6 project. I can set value for any form element by my VB6 code except of the "input type=file" control. Can the code above help me to solve my problem? big_daddy, what is the language of your code is? Thanks. Edited October 16, 2010 by Ivan2
Ivan2 Posted October 16, 2010 Posted October 16, 2010 I've understood where I am and what it is. Trying AutoIt for this task...
DaleHohm Posted October 17, 2010 Posted October 17, 2010 See my sig for an example. 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
Gordon J. Tyler Posted January 5, 2011 Posted January 5, 2011 (edited) This method seems to break starting with Internet Explorer 7. IE will not change focus to the FILE type form field. My code works fine in Internet Explorer 6. Does anyone have an alternative to the _IEAction($oInputFile, "focus") part of this? IE 7 and 8 do allow setting focus on other field types, just not the FILE type. Edited January 5, 2011 by Gordon J. Tyler
DaleHohm Posted January 6, 2011 Posted January 6, 2011 Did you read the reply directly above what you typed? See my sig. 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
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