views:

154

answers:

3

I tried to change the HTML form, input type file. Here is my code:

HTML, form id = form

<input class="upload_file" type="file" id="file" name="file" />

.CSS

I tried both:
.upload_button{
  background: url('../images/upload_btn_bg.png') no-repeat;
  width: 200px; 
  height: 40px;
}

#form input[type=file]{
  background: url('../images/upload_btn_bg.png') no-repeat;
  width: 200px; 
  height: 40px;
}

None of both of those methods works. I did see from some website, like facebook, youtube, google or twitter, they have different style. Wonder how they do it.

+2  A: 

For example, try this variant http://www.quirksmode.org/dom/inputfile.html

Gopher
+3  A: 

You can't do anything with input type file (other than huge hacks). I know this sounds horrible, but the web standards still haven't come up with a solution for that.

What I would suggest though, is that you used something more flexible, such as swfUpload, which let's you change stiles, and also check for file size prior to uploading.

Some neat examples of it can be found here

Hope this helps you

Marcos Placona
ah... I should have asked this question earlier here, instead of spending hours time to debug it. Sigh
learner.php
That's alright. We've all done that :-)
Marcos Placona
A: 

Try this, i hope you get more idea..

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"&gt;
    <html>
         <head>
             <title>Test File</title>
                 <style type="text/css">

         .clsFile
                 {
         border: 1px solid black;
         background-color: red;
         }

         </style>
         </head>
             <body>
         <form action="#">
                <input type="file" class="clsFile" />
         </form>
             </body>
 </html>
VAC-Prabhu
it styles only textbox of control, not button
Gopher
yes, so you can use img tag for buttons <img src="http://yourdomain.com/images/browsebtn.gif"/>
VAC-Prabhu