How to download files using layui

爱喝马黛茶的安东尼
Release: 2019-07-11 14:50:04
Original
12790 people have browsed it

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());
});
Copy after login

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 );
    });
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!