How to hide text field in Html File Upload

后端 未结 12 808
南旧
南旧 2020-12-01 06:50

I am wondering how to hide the text field portion of a standard html file upload tag

for example



        
相关标签:
12条回答
  • 2020-12-01 06:52

    You could possibly hide the whole element and show a button or link instead. This is rather easy.

    <input type="file" name="file" id="fileupload" style="width:200px; display:none;" onchange="submitmyform();" />
    <input type="button" value="Select an Image" onclick="$('#fileupload').click();" />
    

    The file upload element is hidden. The button will fire the click event and shows the file browser window. On selecting a file, the change event is fired and this can submit a form or call a script function, whatsoever.

    Hope this helps...

    0 讨论(0)
  • 2020-12-01 06:53

    This will surely work i have used it in my projects.I hope this helps :)

    <input type="file" id="selectedFile" style="display: none;" />
    <input type="button" value="Browse..." onclick="document.getElementById('selectedFile').click();" />
    
    0 讨论(0)
  • 2020-12-01 06:59

    You can put an image as a background for the button. That worked for me, a while ago.

    0 讨论(0)
  • 2020-12-01 07:08

    The file input button is extremely difficult to style and manipulate, mainly for security reasons.

    If you really need to customize your upload button, I recommend a Flash based uploader like SWFUpload or Uploadify that enables you to use a custom image as button, display a progress bar, and other things.

    However, its basic philosophy differs from just embedding a control into a form. The uploading process takes place separately. Make sure you check out first whether this works for you.

    0 讨论(0)
  • 2020-12-01 07:08

    DEMO

    Pure css and html

    The trick is to use a button above the input file button.

    Plus, you should set

    filter: alpha(opacity=0);
    

    to the input file.

    0 讨论(0)
  • 2020-12-01 07:09

    I'd recommend hiding the whole thing and putting a separate button object which, when clicked, will end up clicking the input's browse button.

    You can do this with CSS and javascript -- check out this article (actually the second time I've used this reference today).

    0 讨论(0)
提交回复
热议问题