问题描述
我要自动选择通过搜索文件
文件输入标签<通过Java脚本输入类型=文件>?
I want to auto select a file through
File input tag < input type=file > via java script ?
我知道这是安全问题,通常不允许。
I know this is security issue and not allowed normally.
但是,这是通过扩展或以任何形式在任何浏览器允许的,
But is this allowed through extensions or in any form in any browser,
由于I M在自动化项目结果工作
这需要一个形式张贴有多个值了
上传功能,上传,然后再提交职位形成(kijiji.ca)
because i m working on a automation project
which requires posting of a form with multiple values hasupload feature which uploads file first and then posts form(kijiji.ca)
和需要用它来完成。
不需要具体哪些有任何浏览器浏览器的自动化功能如Chrome,火狐
need not to be browser specific any browser which have automation capability like chrome, Fire fox
喜弗拉基米尔,我得到它的工作是在弗拉基米尔范围扩展建议。
Hi Wladimir, i got it working as Wladimir suggested in Extension scope.
u能告诉我,如果我需要自动选择多个文件,我应该设置什么样的价值。
Can u tell me if i need to auto select multiple files what value should i set.
我试过设置此
input.value = '"D:\Temp\step1.jpg" "D:\Temp\step2.jpg" "D:\Temp\step3.jpg"'
但不接受它。虽然我可以将其设置为单一的形象,它需要它。
but it don't accept it. Though i can set it to single image and it takes it..
感谢..
推荐答案
Firefox扩展允许设置 input.value
属性,因此像这样将工作:
Firefox extensions are allowed to set input.value
property so something like this will work:
input.value = "c:\\autoexec.bat";
input.form.submit();
然而,当使用附加SDK内容脚本很可能没有必要的权限(需要测试)。在这种情况下,一个需要使用的以及访问网页,而不是直接。
However, when using Add-on SDK a content script will likely not have the necessary privileges (needs to be tested). In this case one would need to use chrome authority and access the web page directly rather than via a content script.
至于铬,扩展程序有没有访问到文件系统 - 以便适用于网页上的安全限制正在申请的扩展为好。允许扩展到一个文件上传控件的值设置将是一个安全问题存在。所以我pretty肯定,这是不可能的。
As to Chrome, extensions there don't have access to the file system - so the security restrictions that apply to web pages are applying to extensions as well. Allowing extensions to set the value of a file upload widget would be a security issue there. So I'm pretty sure that it isn't possible.
这篇关于通过浏览器扩展,通过文件输入标签浏览器自动选择文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!