Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I'm using plupload to client scaling of pictures before they are uploaded. I like the feature that it gracefully falls back to html4 if the user doesn't have flash, silverlight etc engines installed.

I want to be able to start the upload when the user clicks certain elements on the page and i want to handle the events (sometimes stopping a file dialog from opening). In fact i'd like to pop open the file dialog using javascript.

Ok, so HTML4 (or rather the browser, except chrome :P) won't let me do this, unless the user clicks a browse-button (or an overlay covering a browse-button), so when i get the fallback to HTML4 i'll accept that i can't do it, but most users will have flash or silverlight installed and they do not have this restriction. So my question is this:

How do i trigger the file open dialog in plupload (keeping in mind i only need the flash and silverlight engines to do this).

share|improve this question

3 Answers

Hey Per Hornshøj-Schierbeck,

Read your problem.

I found some articles that may help to figure this out. check them. It may help...!

01. In JavaScript can I make a "click" event fire programmatically for a file input element?

02. open file dialog box in javascript

Regards, ADynaMic

share|improve this answer
Both your solutions are concerning javascript/html4 and neither actually work for the situation i need. I know my question is pretty specific, but i only need this functionality in pluploads silverlight and flash engines, not in html4 – Per Hornshøj-Schierbeck Mar 15 '11 at 22:47
up vote 1 down vote accepted

Ok. It doesn't seem possible to do this, so unless someone implements event handles for the silverlight and flash components i'm out of luck

share|improve this answer
1  
Actually Flash and Silverlight won't let you to trigger file dialog programmatically. It is allowed to happen only as a reaction to some event like mouse click (help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/…). – jayarjo Apr 5 at 11:56

If someone is searching for the HTML5 solution, here it is:

var up= $('#uploader').pluploadQueue();
if (up.features.triggerDialog) {
    plupload.addEvent(document.getElementById('idOtherButton'), 'click', function(e) {
        var input = document.getElementById(up.id + '_html5');
        if (input && !input.disabled) { // for some reason FF (up to 8.0.1 so far) lets to click disabled input[type=file]
            input.click();
        }
        e.preventDefault();
    }); 
}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.