SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Addict
    Join Date
    Apr 2003
    Posts
    208
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    File Upload Javascript

    Hey

    Okay is there any way to bring up a "File Upload" box by clicking on an input button?

    <input type="file" size="65" /> is the default method, it shows a input box and a browse button when used. However this doesn't allow for styling of the input button, which is necessary in this case.

    So is there any way via JavaScript I can imitate the action of the Browse button using a normal input button?

    Regards
    Chris

  2. #2
    Chive On FFCus's Avatar
    Join Date
    Feb 2006
    Location
    Connecticut
    Posts
    542
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you're looking to add style to the "Browse" button, check this out:
    http://www.quirksmode.org/dom/inputfile.html

  3. #3
    SitePoint Addict
    Join Date
    Apr 2003
    Posts
    208
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hmm thanks FFCus, I've just checked that out, nice, but it doesn't really work too well. Isn't there any JS that can be applied to a normal button?

  4. #4
    CSS & JS/DOM Adept bronze trophy
    Join Date
    Mar 2005
    Location
    USA
    Posts
    5,482
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No. That is the only way to do what you want. (unless there is a way to use Flash or a Java Applet, both of which would be more trouble then they're worth)
    We miss you, Dan Schulz.
    Learn CSS. | X/HTML Validator | CSS validator
    Dynamic Site Solutions
    Code for Firefox, Chrome, Safari, & Opera, then add fixes for IE, not vice versa.

  5. #5
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,784
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    Both the input field and the button are displayed however the browser and Operating system tell it to display and you only have limited access from the CSS to change it.

    If you don't like the way it looks in one browser then take a look at the page in a different browser. It will almost certainly look different there anyway.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •