MacGapProject / MacGap2

MacGap 2
MIT License
1.2k stars 84 forks source link

Unable to select multiple files using input type file #75

Closed anku94 closed 8 years ago

anku94 commented 8 years ago

Hi

I'm unable to use the File Upload dialog to select multiple files in MacGap using the following HTML5 element.

<input type="file" multiple="multiple">

This works fine in my Safari (and is supposed to be fully supported since Safari 5.0)

User Agent in my MacGap:

Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_4) AppleWebKit/600.7.12 (KHTML, like Gecko) MacGap

(The same issue persists across both MacGap1 and MacGap2 - I also created the same issue for MacGap1)

anku94 commented 8 years ago

So I dug into the MacGap code, and it seems that the Open Dialog Box behavior is described within runOpenPanelForFileButtonWithResultListener in Classes/WebViewDelegate.m

It does provide a parameter allowMultipleFiles which should be passed as a parameter to openDlg.setAllowsMultipleSelection but isn't. That's a bug, right?

jeff-h commented 8 years ago

If you pass true to allowMultipleFiles then the dialog will always allow multiple right? i.e. it still won't honour the multiple="multiple" part of the input tag. If you're able to get it doing that, it would be great!

anku94 commented 8 years ago

No, you misunderstand me. allowMultipleFiles is an argument to runOpenPanelForFileButtonWithResultListener. It seems webkit parses the HTML source and sets the flag to true if multiple=multiple is there, and false if it's not. We just need to forward that flag to openDlg.

I was just confused why this has not been done already. It's a trivial one-liner, and I wondered if it might have anything to do with compatibility issues.

jeff-h commented 8 years ago

Sorry about that! My guess it's just an oversight. Could you make a pull request for this?