This is a migrated thread and some comments may be shown as answers.

Open file selection using javascript

4 Answers 184 Views
AsyncUpload
This is a migrated thread and some comments may be shown as answers.
Shukhrat Nekbaev
Top achievements
Rank 1
Shukhrat Nekbaev asked on 23 Mar 2011, 02:48 PM
Hi,

I need to trigger file selection dialog based on some concrete event, afaik, currently I can trigger it if it's rendered as input, but same trick, obviously, doesn't work when control is rendered as <object> (multiple file selection case). Question is do you have, if not then consider as feature request, abilitiy to trigger file selection dialog from JS. In my current project I have flash object and we communicate through JS, I feel like something similar could be useful.

Thank you!

4 Answers, 1 is accepted

Sort by
0
Helen
Telerik team
answered on 25 Mar 2011, 05:14 PM
Hello Shukhrat,

Actually we plan to implement a similar functionality in the near future.

Your points have been updated for the nice suggestion.

Regards,
Helen
the Telerik team
0
SamVanity
Top achievements
Rank 2
answered on 23 Sep 2011, 07:37 AM
Is this capability available now?

I am thinking about using a button on the editor to bring up the open file dialogue. Programmatically clicking on the file input button doesn't seem to work on chrome (fileAPI) or IE(silverlight).
0
SamVanity
Top achievements
Rank 2
answered on 23 Sep 2011, 08:16 AM
I was referring to a button on a WYSIWYG editor in my previous post.

I was able to achieve the effect with Chrome by setting the following CSS on page
.RadUpload .ruFakeInput,
.RadUpload .ruBrowse,
.RadUpload .ruFileWrap {display: none}

and bind the following handler to the editor button:

$('#editorButton').click(function () {
    var $inputFile = $('input:file').eq(0);
    $inputFile.closest('span').css('display', 'inline-block');
    $inputFile.click();
    return false;
});

However, this doesn't work with IE because IE uses silverlight. Any way we can trigger silverlight file dialogue?
0
Genady Sergeev
Telerik team
answered on 26 Sep 2011, 04:39 PM
Hello Sam Van,

This approach is not cross browser and won't work in some old browser as well. As for IE, there is no way to trigger the Silverlight dialog with JavaScript, however, it is possible to disable Silverlight/Flash and stick to the IFrame module for IE. Here is how:

Telerik.Web.UI.RadAsyncUpload.Modules.Flash.isAvailable = function () { return false; };
Telerik.Web.UI.RadAsyncUpload.Modules.Silverlight.isAvailable = function () { return false; };


All the best,
Genady Sergeev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Tags
AsyncUpload
Asked by
Shukhrat Nekbaev
Top achievements
Rank 1
Answers by
Helen
Telerik team
SamVanity
Top achievements
Rank 2
Genady Sergeev
Telerik team
Share this question
or