5

this is upload file code:

<form>
<input type="file" name="file"/>
</form>

It's appear a text box and BROWSE button to upload a file.

Well, But is there any way to upload a file by just click on "some" text, Example: "Upload your file" text. After click on this text then upload box will appear.

1
  • yes this is possible apply some css on the input tag and you are done Commented Apr 21, 2012 at 7:18

3 Answers 3

2

Try this

http://jsfiddle.net/RffbE/

<form>
<input type="file" name="file" id="file" style="display:none"/>
<span onclick="doTrick()">Upload your file</span>
</form>

and use this javascript function.

function doTrick() {
    document.getElementById('file').click();
}
Sign up to request clarification or add additional context in comments.

Comments

0

I guess you need this

Please see my jsfiddle

jsfiddle : http://jsfiddle.net/ks5r7/6/

    <html>
    <head>
        <script>
            function show()
            {
                document.getElementById('box').style.display='inline';
            }

        </script>
    </head>
    <body>
        <div id="show"><a href="#" onclick="show()">Upload my file</div>

        <div id="box" style="display:none";><input type="file"/></div>
    </body>
</html>

You can style each element here

Comments

-2

Directly you can't set any css on input type file you need to use trick for this. see this plugin

1 Comment

Whilst this may theoretically answer the question, we would like you to include the essential parts of the linked article in your answer, and provide the link for reference. Failing to do that leaves the answer at risk from link rot.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.