How to modify the browse button of an uploaded file to a custom button

Source: Internet
Author: User

Recently, in the modification of an internationalized project, encountered a place to upload files, to be displayed as the browse button to customize the English button brows, although the button will automatically switch according to the system language, but it is in their own computer to look uncomfortable, do not want to change into English.

The general idea is: To hide the real file, using the normal text and buttons to stitch into our file upload style. Then set the button's OnClick event, which responds to the file's click event, and finally sets the file's OnChange event, which populates the value of the file with value in text (that is, the upload path of the document) when file changes.

The code is as follows:

<form action= "Fileuploadservlet" enctype= "Multipart/form-data" name= "Fileuploadform" >
<input type= "File" Name= "Docfile" id= "Docfile" style= "Display:none;"
Onchange= "Document.fileuploadform.filepath.value=this.value"/>
<input type= "text" name= "FilePath" id= "FilePath"/>
<input type= "button" value= "Brows" onclick= "Document.fileUploadForm.docFile.click ()"/><br>
<input type= "Submit" value= "Submission"/>
</form>

The page is as follows:

  

The corresponding files and file names can be obtained in the background:

  

How to modify the browse button of an uploaded file to a custom button

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.