search
HomeWeb Front-endLayui TutorialHow to download files using layui

How to download files using layui

Jul 11, 2019 pm 02:50 PM
layuidownload file

How to download files using layui

Download: The href attribute in the

a tag can directly give the download link address. When clicked, it will The download and save window will pop up automatically.

Use the native upload file tag to upload files and get the full path of the uploaded file:

$('#file').change(function(){
    $('#em').text($('#file').val());
});

Related recommendations: "layui framework tutorial"

Get the file Name:

var file = $('#file'),
    aim = $('#em');
    file.on('change', function( e ){
        //e.currentTarget.files 是一个数组,如果支持多个文件,则需要遍历
        var name = e.currentTarget.files[0].name;
        aim.text( name );
    });

Note: e.currentTarget.files[0].name is files, not file

Use sessionStorage to pass a large number of parameters between pages.

Object object traversal is available, $.each() method, the first parameter is the object to be traversed, and the second parameter is the callback function. For specific usage, see the jquery manual.

The above is the detailed content of How to download files using layui. 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

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment