如何在不使用或隐藏<input type =“file”/>的情况下上传图像?

时间:2017-12-19 05:42:26

标签: php html ajax upload image-uploading

我正在创建一个php脚本,我从目标本地计算机驱动器中获取目录和文件列表。

现在,我想要实现的是,当我点击列表中的特定图像名称时,它会上传到我的服务器。

我不想使用&#34;浏览/输入类型=&#39;文件&#39;&#34;按钮。

我尝试了几种但尚未成功的方法。

请帮助。

提前致谢。 H甘地

1 个答案:

答案 0 :(得分:0)

&#13;
&#13;
$('button').click(function(){
    $('input').click();
});
&#13;
input {
    display: block;
    visibility: hidden;
    width: 0;
    height: 0;
}
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="file" name="somename" size="chars">
<button>Choose File Button</button>
&#13;
&#13;
&#13;