jQuery自定义文件输入插件 [英] Jquery custom file input plugin

查看:63
本文介绍了jQuery自定义文件输入插件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此jquery插件允许您将任何元素转换为文件输入元素. http://plugins.jquery.com/project/custom-file

This jquery plugin allows you to turn any element into a file input element. http://plugins.jquery.com/project/custom-file

但是要真正上传文件,我唯一能找到的文档是这样的:

But to actually upload the file, the only documentation i could found is this:

要将所选文件上传到服务器,您应该将输入元素附加到表单元素

To upload the chosen file to a server you should then attach the input element to a form element

我该怎么做?

推荐答案

我认为您需要创建html表单并将输入内容附加到表单,如果需要提交,则可以通过提交"按钮或通过$ .submit

I think you need to create an html form and append the input to the form, and if you need to submit, you can do it via a submit button or via $.submit

    # from http://www.daimi.au.dk/~u061768/file-input.html
    <script type="text/javascript">
$(function() {
    $('button').button().add('#foo, a').file().choose(function(e, input) {
        $(input).appendTo('#TheForm').
                         attr('name', 'a-name').
                         attr('id', 'an-id');
    });


});
    </script>
    ...
    <form method="post" enctype="multipart/form-data" id="TheForm" action="/path/in/your/server/">
    <input type="submit" value="send">
    </form>

无论如何,这不是通过ajax提交文件的最佳插件.

Anyway this is not the best plugin for submiting the files via ajax.

这篇关于jQuery自定义文件输入插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆