Skip to main content
gamedev.net
🔒 Locked

[web] [Javascript] File Input question

Started by Ruudje 5 replies 850+ views
Original Post
Ruudje
Ruudje
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
markr
markr
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
Ruudje
Ruudje
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..
Wan
Wan
It's just not possible.
benryves
benryves
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!
[Website] [+++ Divide By Cucumber Error. Please Reinstall Universe And Reboot +++]
evolutional
evolutional
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 ;)
Ruudje
Ruudje
So it really isn't an option.. Well at least I know for sure now ;) Tnx guys/girlz

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.