Uploading a File with AppleScript via JavaScript
Hi everybody,
being new to AppleScripting and JavaScripting I'm faced with the following problem:
Is it possible to make AppleScript to input the path for a file to be uploaded via JavaScript? If yes, what should be the correct Path Format and how to wrap it up the JavaScript action into AppleScript? I've tried a few comands but to no success.
On the webpage in question, there's a "Choose" button, that is defined as follows:
<input type="file" class="gwt-FileUpload" name="swfFile">
I've been trying to use the following syntax:
do JavaScript "document.getElementsByName('swfFile')[0].value('Macintosh HD:Users:myaccount:Desktop:Scrapbook:!动画.swf')" in document 1
as well as this one, where the Path is definitelly understood by shellscript:
do JavaScript "document.getElementsByName('swfFile')[0].value('/Users/myaccount/Desktop/Scrap book/!动画.swf')" in document 1
The name of the file is (and must remain) in chinese, but for testing purposes I have also tried files with english names, without success.
Currently I'm using a solution with JavaScript comand:
do JavaScript "document.getElementsByName('swfFile')[0].click()" in document 1
to click the finder window to browse for the file, and manipulating keystrokes by using System Events to find the right file, but it's not infallible with a number of files and it's hardly an ellegant sollution.
Any idea what I'm doing wrong?
Cheers!
MacBook Pro, Mac OS X (10.7.4)