Jump to content

type=file


Recommended Posts

I want to know, what is wrong

Autoit-Code:

$o_file = _IEFormElementGetObjByName($o_form, "userfile")
_IEFormElementSetValue ($o_file, "Hello.txt")

the source-code of the website:

<td class="inputDescription">Lokale Datei:</td>
    <td><input type="File" name="userfile"></td>

I don't know, why the program doesn't send "Hello.txt" into the field.

It is because of "type="file""?

How can I solve this problem?

Can you help me?

Thank you

Edited by Seth27
Link to comment
Share on other sites

I tried this with a complete path.

The original code is:

$o_IE = _IECreate () 
_IENavigate ($o_IE, "website")

$o_form = _IEFormGetObjByName($o_IE, "login_form")
$o_login = _IEFormElementGetObjByName($o_form, "login")
$o_password = _IEFormElementGetObjByName($o_form, "passwd")
_IEFormElementSetValue($o_login, "loginname")
_IEFormElementSetValue($o_password, "passwd")
_IEFormSubmit($o_form)

$FileList=_FileListToArray("C:\income", "*.*", 1) 
For $i = 1 To Ubound($FileList) - 1
$o_form1 = _IEFormGetObjByName($o_IE, "form1")

$o_file = _IEFormElementGetObjByName($o_form1, "userfile")
$o_name=_IEFormElementGetObjByName($o_form1, "fname")

_IEFormElementSetValue ($o_file, "C:\income\" & $FileList[$i])
_IEFormElementSetValue($o_name, $FileList[$i])

_IEFormSubmit($o_form1)
Next

The type of fname is text and the type of userfile is file. In fname it writes the name but in userfile it write nothing. I don't know if it is because of the type="file" of userfile.

Link to comment
Share on other sites

  • Moderators

For obvious security reasons you are not allowed to script a <input type=file>. However this is a workaround:

#include <IE.au3>

$sFilePath = "C:\test.txt"

$oIE = _IE_Example("form")
$oForm = _IEFormGetObjByName($oIE, "ExampleForm")
$oFile = _IEFormElementGetObjByName($oForm, "fileExample")

$oFile.focus
Send($sFilePath)
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...