search
HomeWeb Front-endLayui TutorialHow to get the file name in layui's file upload function

How to get the file name in layui's file upload function

The first step is to open the software on our computer, create a new html page, and add the css, js file and jquery.js file of the layui plug-in, as shown below:

How to get the file name in layuis file upload function

The second step is to first introduce the three files layui.css, layui.js, and jquery-1.9.0.js into the newly created index1.html file, as shown in the figure below :

How to get the file name in layuis file upload function

The third step is to add a table, file selection and file upload buttons in the body of index1.html to upload the file to the server in the form of a table Display to the interface, display the file name, file size, etc., as shown below:

How to get the file name in layuis file upload function

The fourth step is to open the page in the browser and you can see the file upload list. The interface effect is as shown below:

How to get the file name in layuis file upload function

Related recommendations: "layui framework tutorial"

The fifth step is to start giving files Add events to the select button and upload button, and return the uploaded file information to the table. Use the obj.preview(function(index, file, result){}); method to read the selected local file information and obtain file.name File name, (file.size/1014).toFixed(1) gets the file size, as shown in the figure below:

How to get the file name in layuis file upload function

Step 6 Click the upload file button to upload the selected one After the file is successfully uploaded, the file upload information, including file name, file size, etc., is obtained through the var tr=demoListView.find('tr#upload-' index), tds =tr.children(); code and inserted into the table. As shown in the picture below:

How to get the file name in layuis file upload function

The seventh step is to open the index1.html file in the browser. You can see the interface style for uploading multiple files. Click to select multiple files, as shown below. As shown:

How to get the file name in layuis file upload function

In the eighth step, we select the local file to upload and click to open, as shown in the figure below:

How to get the file name in layuis file upload function

In the ninth step, you can see that the file has been successfully uploaded to the server, and the file name and file size are obtained and displayed in the table, as shown in the following figure:

How to get the file name in layuis file upload function

The above is the detailed content of How to get the file name in layui's file upload function. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor