Need to programmatically call the Upload 'browse... ' function

I don’t want to use the Upload “Browse…” button and have therefore blocked its display. Next, I want to call the method that clicking the Browse button calls in the Upload class to open the system file directory for the user to select a file to upload.

Any suggestion would be welcomed.

Thanks

Have you tried to call setImmediate(true) for your Upload component? It kind of does what you want: it hides the browse button and the file name label and instead opens the file dialog just when you click on Upload button.

Thanks for your suggestion, it is not what I want. I have also blocked the “Upload” button.

I want to replace all the Upload buttons with one MultiButton – parent to four buttons (“Select file”, “Upload”, “View…”, and “Delete”). This is much neater in a form.

Question:

Which method is called when one clicks the Upload component “upload” button – when it is in the immediate mode?

As far as I know, triggering upload in the browser from the server side is not possible - browsers prevent it for security reasons and to prevent disturbing the user.

You can probably play tricks to implement this the way the immediate mode upload does (a hidden upload element on top of the visible button so that clicking it is a direct user action) but this might require some client side coding/extension. I’m not sure if this can also be done from JavaScript that is triggered directly by a user action, but not from JavaScript that is triggered by a server reply.