JavaScript input Type=file File upload

Source: Internet
Author: User

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

Related Article

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.