用JavaScript填写输入文件表单 [英] Fill input file form with JavaScript

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

问题描述

我需要用JavaScript填充HTML表单来设置文件的上传路径。这个表单所属的网页已经有了一个可视化上传的实现,但是

 < form id =mobile_fileform> 
< input type =filestyle =height:20px; width:0px; opacity:0;id =mobile_fileselect1multiple =size = - 17>
< input type =filestyle =height:20px; width:0px; opacity:0;id =mobile_fileselect2multiple =size = - 17>
< input type =filestyle =height:20px; width:0px; opacity:0;id =mobile_fileselect3multiple =size = - 17>
< / form>

如何在此窗体中设置文件的路径,以及如何使用JavaScript上载文件?



感谢您的帮助 属性 input:file 为只读。如果你想设置它,你需要做服务器端。



因此,你要做的是不可能即可。考虑一下它的含义:只要知道路径,任何网页都可以上传任何文件。


I need to fill an HTML form with JavaScript to set the path of a file for upload it. The web that this form belongs to, already has a visual upload implemented, but

<form id="mobile_fileform">
    <input type="file" style="height: 20px; width: 0px; opacity: 0; " id="mobile_fileselect1" multiple="" size="-17">
    <input type="file" style="height: 20px; width: 0px; opacity: 0; " id="mobile_fileselect2" multiple="" size="-17">
    <input type="file" style="height: 20px; width: 0px; opacity: 0; " id="mobile_fileselect3" multiple="" size="-17">
</form>

How can I set the path of the file in this form and how can I upload it using JavaScript?

Thanks for your help

解决方案

The value property of input:file is read-only for security reasons. If you want to set it, you'll need to do it server-side.

As a result, what you're asking to do is not possible. Consider the implications: any webpage would be able to upload any file from someone's computer, so long as they knew the path.

这篇关于用JavaScript填写输入文件表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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