tags:

views:

1209

answers:

2

I'd expect the following to open file dialog, but it doesn't. Why?

$('<input type="file"/>').click();
+2  A: 

I'd consider that hazardous if my browser popped up system dialogs unrequested. Just a thought that it's probably a security restriction. I certainly could be wrong in this case.

altCognito
One can make your browser pop up file dialog in an non obvious way. Using this plugin for instance: http://plugins.jquery.com/project/ocupload
artemave
@artemave, as far as I can tell, that plugin still requires a click in order to popup the dialog.
Ionuț G. Stan
Yeah, but this click may not be meant to open file dialog at all. Anyway, your answer makes sense and definitely postponed a bit the inevitable brain failure I am doomed to end up with being a web developer.
artemave
+6  A: 

It's not (shouldn't be) possible to programmatically open file dialogs. The standards say so.

I said shouldn't as IE6 allows this, AFAIK.

Ionuț G. Stan