In JS, input type=file is commonly used in the file upload API, but feel that the network is not very clear, at the same time the online information is also more chaotic.
As a result of development, so the Web site intends to use less third-party libraries or plug-ins to speed up the loading of web pages. Because the enterprise number itself wants to realize the function is also very pure, does not need too many messy things.
I only use jquery here.
Summarized as follows:
1. When the user selects a file, it usually displays only one fakepath and does not display a complete file directory. Use $ ("input[type= ' file ']") [0].files[0].name to display the file name.
2.$ ("input[type= ' file ']") [0].files[0].type Displays the file type, such as "application/vnd.ms-excel", but not the file suffix name.
3.$ ("input[type= ' file ']") [0].files[0].size shows the number of bytes of files to be converted in actual use.
JavaScript input Type=file File upload