如何在点击图片按钮上传新文件 [英] How can I upload a new file on click of image button

查看:139
本文介绍了如何在点击图片按钮上传新文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个任务要从点击图片按钮上传新文件。
我的代码是

I have got a task to upload new file from the click of image button. My code is

    <label>File</lable>
    <input type="image" src="http://upload.wikimedia.org/wikipedia/commons/c/ca/Button-Lightblue.svg" width="30px"/>

点击这个按钮我想上传一个新文件。
您可以从
中检查我的代码演示

On the click of this button I want to upload a new file.How can I do this? You can check my code from Demo

推荐答案

您可以添加隐藏文件输入字段,例如:

You could add a hidden file input field, like:

<input type="image" src="http://upload.wikimedia.org/wikipedia/commons/c/ca/Button-Lightblue.svg" width="30px"/>
<input type="file" id="my_file" style="display: none;" />

并执行:

$("input[type='image']").click(function() {
    $("input[id='my_file']").click();
});

演示:: 更新小提琴

这篇关于如何在点击图片按钮上传新文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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