Style File Input

Styling File Inputs

To add custom style file inputs, include FileUI.js in the head section of your HTML.

Html:
  1. <script src="fileUI.js" type="text/javascript"></script>

Example 1: Adding custom button with rollover.

Example of file inputs with a custom button:

XHTML Markup

Html:
  1. <span class="fileInputSpan"><input type="file" /></span>

Add this directly after all of your input fields.

Html:
  1. <script type="text/javascript">
  2. var styleInputs = FileUI
  3. styleInputs.imgPath = 'browse.gif'
  4. styleInputs.imgPathOver = 'browse_over.gif' // optional mouse over image
  5. styleInputs.init()
  6. </script>

Example 2: Replacing button with link.

Example of file inputs with a link for a button:

XHTML Markup

Html:
  1. <span class="linkDemo"><input type="file" /></span>

Add this directly after all of your input fields.

Html:
  1. <script type="text/javascript">
  2. styleInputs.textOnly = 'ButtonText'
  3. styleInputs.spanClass = 'linkDemo'
  4. styleInputs.init()
  5. </script>

Add some style to the link.

Html:
  1. <style type="text/css">
  2. .linkDemo a {
  3. background: #000
  4. color: #eee
  5. padding: 1px
  6. }
  7. .linkDemo a.over {
  8. background: #555
  9. font-weight: bold
  10. }
  11. </style>