Blogger Information
Blog 33
fans 0
comment 1
visits 43117
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
JQuery 异步上传文件
萝卜温的博客
Original
874 people have browsed it
<form id="uploadForm" enctype="multipart/form-data">    
    <input id="myfile" type="file" name="myfile"/>
    <button id="upload" type="button">上传</button>
</form>
<script>
$.ajax({
    url: 'upload.php',
    type: 'POST',
    cache: false,
    data: new FormData($('#myform')[0]),
    //不需要处理数据,因为数据是一个FormData对象
    processData: false,
    //不需要指定内容,因为form标签已经指定了内容的类型
    contentType: false,
    dataType: 'json',
    success: function (data) {
        console.log(data);
    }
});
</script>

注:具体细节,参考下面链接:

通过jQuery Ajax使用FormData对象上传文件

Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post