• Advertisement
Sign in to follow this  

[web] [Javascript] File Input question

This topic is 4795 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I know that gamedev isnt really about this sort of thing but I couldnt find the info i am looking for on google, and don;t know where else to ask, so: Can I add a file-input object to a form, and hide it, and let the select-file-dialog show up by clicking something else? The whole reason is that I don't want to show the text-part of the file-input, just a button, and an icon showing a file has been selected, or is yet to be.. tnx in advance

Share this post


Link to post
Share on other sites
Advertisement
No you can't.

As far as I'm aware, you can't script file input elements whatsoever. You can't attach events to them (or they won't fire anyway). You definitely can't script the contents of them, and you can't affect the button's behaviour in any way.

This does make sense however, as the file upload control could easily be used to do nasty naughty things if the web author had any level of control over its behaviour.

I think you can probably show / hide it by creating a container element and setting style properties on that. But that's probably about it. There aren't any methods or events you can use.

Mark

Share this post


Link to post
Share on other sites
I know I can't alter the contents of it (security risk) but all i wanted is to trigger the input, as if someone clicked on the browse-button..

Share this post


Link to post
Share on other sites
Far from perfect, I know, but you could always embed the Common Dialog ActiveX control onto your page... but this is really not a good plan at all. Only do this if you're desperate to do it this way!

Share this post


Link to post
Share on other sites
The last thing I'd want to do is download an unsigned ActiveX control from a website to use it - not that I could, being on Linux and all, but the principle is still there. You did say last resort though ;)

Share this post


Link to post
Share on other sites
So it really isn't an option.. Well at least I know for sure now ;) Tnx guys/girlz

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement