My favorites | Sign in
Project Home Downloads Wiki Issues Source
New issue   Search
  Advanced search   Search tips   Subscriptions
Issue 2239: support <input type=file multiple>
91 people starred this issue and may be notified of changes. Back to list
Status:  Accepted
Owner:  ----

Sign in to add a comment
Project Member Reported by jari.bakken, Aug 11, 2011
WebDriver should handle <input type=file multiple> et. al.

simonstew : We may need to end up making some changes to the wire protocol to support that
    jarib : hmm
    jarib : ok
simonstew : The problem we face is that we're using "sendKeys" to set the value of a file input element
simonstew : which made sense Back In The Day
    jarib : yep
simonstew : But now we need to do "something else"
simonstew : The first step will be a "file upload" API, which we won't expose to users
simonstew : And then.... profit!
simonstew : We'll figure it out
simonstew : Knowing what the user facing API will be is the most important thing
simonstew : Everything else can be made to flow from that

Aug 25, 2011
Project Member #1 jari.bakken
This enhancement should include a solution to our lack of attachFile for remote / grid as well.
Aug 30, 2011
Is there any chance prior to the work on a generally improved file upload API, for sendKeys on file inputs being able to support multiple file inputs?  (Which doesn't seem to be supported at the moment.)

See here:!searchin/selenium-users/multiple/selenium-users/bhDAYG0-nE0/yIG1b2XG0QIJ
Aug 30, 2011
Project Member #4 jari.bakken
@2: This issue was created to solve that problem. That said, multiple file uploads do actually work in Chrome with sendKeys:

  driver.sendKeys(path1, path2)

That may have been changed in this recent revision though:
Aug 30, 2011
Project Member #5 jari.bakken
 Issue 594  has been merged into this issue.
Oct 6, 2011
My work around has been to use AutoIT, which I invoke from a selenium test, blocking until AutoIT completes. New browsers expicitly prohibit javaScript from interacting with an input tag of type file.
Nov 3, 2011
Is there any change that this will get into the next 2.12.0 release?
A lot of ppl really seem to be waiting on this.
Nov 3, 2011
Yes, yes, do something with this! ;)
Nov 22, 2011
Project Member #9 simon.m.stewart
This has been implemented for clients of the RemoteWebDriver server (and only those). Since all other drivers are expected to be local host or it makes no sense for them to upload files (eg: mobile drivers) I believe that this issue is resolved.
Status: Fixed
Nov 23, 2011
Project Member #10 jari.bakken
@simon: I thought the goal of this issue was to also deal with <input type=file multiple>.
Jan 3, 2012
Project Member #11 jari.bakken
I'll take that as an "oops" :)
Status: Accepted
Jan 3, 2012
Project Member #12 jari.bakken
(No comment was entered for this change.)
Summary: support <input type=file multiple>
Feb 28, 2012
Hi guys:

At Mozilla this problem is hitting us pretty hard as we try to test our new Apps Marketplace.  Currently, we're trying to automate a test for submitting an app which involves uploading a screenshot.  We can do this easily enough on a standalone, local instance of Se-Webdriver with send_keys, but we run our tests on a grid. 

It looks a lot like  bug 594 , although that one has been merged into this one, so I'm commenting on this bug.

Currently, we will have to either install an image on each box in the grid which is "dodgy" because it will introduce some flakiness and extra maintenance or we will have to "get creative."  

Is there anything those of us at Mozilla can do to support the fixing of this bug?  If there is, let me know.  I lurk in the Selenium channel every day so feel free to ping me there.
Feb 28, 2012
Project Member #14
For the file remote code mention in  issue 594  I need to fix  issue 3459  for python. 
Aug 8, 2012
Is anybody looking into this issue?

Aug 8, 2012
On a related note, there's no planned support for multiple file upload from a single input file element (i.e. HTML5-based file uploader with multiple file upload/selection support) or is there?
Aug 8, 2012
Project Member #17 jari.bakken
@mangaroo: That's exactly what this issue is about.
Aug 8, 2012
Ok, thanks, just what I wanted to know.

Also regarding this topic, is file upload multiple standardized on how browsers actually perform the upload? Is it a normal form POST with multi-part form data but with multiple files sent or is it much more than that and can vary by site/code & browser implementation? It was typically easier with single file upload, at least with the traditional form POST method (as opposed to AJAX).

But I'm assuming multiple file uploads today are typically AJAX based through HTML5, etc. Just wanted to bring this up as for our site implementation, there is javascript code that is triggered when file upload element is set with value of the files. The javascript then performs multiple file upload via AJAX in parallel for 3 files at a time. Considering this type of implementation, one way to support this for WebDriver (though not an all in one solution) would be to allow sendKeys to set file input element value (with multiple files - is it stored as array or CSV type string?) but not actually perform upload. User can then trigger the javascript, etc. that actually performs the upload. Supposedly one could try to do that all in javascript then but browser security prevents setting file input element value, so that part has to be done via WebDriver. If considering this approach for backwards compatibility and single file upload, need to introduce way to specify whether sendKeys will upload file or just set value of file input element.
Aug 9, 2012
The best source of information is definitely

RFC1867 ( specifies the CGI interface for multiple file upload, see section 6 Examples.

However for this issues, I assume the CGI interface is irellevant, because sellenium is intended to instruct the browsers to perform the upload.

As far as I understand In HTML5 there are proposed a JavaScript/DOM FILE API (see that allow access to files via the DOM interface.

Maybe the File API is usefull for implementing this feature in sellenium.

Commenting on "Considering this type of implementation, one way to support this for WebDriver (though not an all in one solution) would be to allow sendKeys to set file input element value (with multiple files - is it stored as array or CSV type string?) but not actually perform upload"

The problem is really that THERE IS NO VALUE for a single input element (of type=file and having attribute 'multiple') that is equivalent to selecting 2 files...

If you select 2 files in one input element. The closest equivalent DOM is actually two elements. That is if the source HTML is
<input type='file' name='files' multiple>
 and you select two files, then the browser shall send (the CGI dictates that) what the following HTML (with two identical elements) would send
<input type='file' name='files' multiple>
<input type='file' name='files' multiple>

For that reason most backend server implementations (PHP and RoR) usually use a name ending with '[]' such as
<input type='file' name='files[]' multiple>
because that naturally ends up in an array named 'files' on the server side. Such that when the CGI parameters arrives with several entries for the same attribute name ('files[]') they will naturally be pushed onto the array named 'files'

Aug 9, 2012
Thanks for the insight, that's helpful to know. 

Actually our site does have attribute of multiple="multiple" in the file input element, I overlooked it since it used the same name as the single file upload element (it checks browser and defaults to that one if HTML5 not supported and Flash not installed).
Feb 26, 2013
Any progress on this issue ?
Feb 26, 2013
I have created so that everyone can see how a CGI application receives data in the case of uploading multiple files.

You are welcome to try it out, it may even be useful for exploratory testing ( in an attempt to implement this feature for selenium.

Feb 26, 2013
On comment #22, has that tool been thoroughly tested? I'm not sure its implemented correctly. I don't know about non-HTML5 multi-file form based upload. But if we're talking HTML5 based multiple file uploader, you might need to add some additional code/logic on the client side to do the upload correctly.

Without even doing the upload, I notice possible issues:

Select your files but don't upload yet. Query via javascript for the value set when browing for the multiple files. e.g. execute "document.getElementById('upload_files').value" w/o quotes in the javascript console of browser. I saw only 1 file out of n selected in Chrome and FF. Interestingly, in Chrome the UI showed "2 files" next to the file uploader button to show that 2 files were selected but querying the value only returns 1. I would have expected the console to spit out a javascript array (or object) for you to inspect. Similarly, if you perform the submit, it will just spit out the single file mentioned when you query the console.
Jul 27, 2013
At comment#23: There is nothing wrong with the tool. The issues you experience is not a problem with the tool, more a problem with the browser and/or javascript engines you are using. It even emphasizes the need for such a simple testing tool to test browsers and/or browser automation frameworks like selenium. For more discussion about the tool, please see the issue
Mar 22, 2014
Project Member #26 luke.semerau
 Issue 7099  has been merged into this issue.
Sep 6, 2014
Continuing from  Issue 7099 , has anyone had any luck with uploading multiple files in FIREFOX with sendkeys? Is there a way to "watch" what the browser receives when a user drags a group of files onto a <input> set to multiple? THX!
Sep 16, 2014
Also interested in doing it with keystrokes.
Yesterday (33 hours ago)
Any news on when this might be fixed? 
Sign in to add a comment

Powered by Google Project Hosting