如何从文件控制中获取完整路径??? [英] How to get Full path from file control???

查看:105
本文介绍了如何从文件控制中获取完整路径???的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从文件控件获取完整路径(以下代码在MOZILLA中不起作用)

How to get Full path from file control (Below code is not working in MOZILLA)

<body>
<script type = "text/Javascript" >
function show_filename()
{
var filename = document.getElementById('eve').value;
alert(filename);
}
</script>
<form>
  <p>
  <input name="text1" type = "<strong class="highlight">file</strong>" id = "eve" size = "40" >
  </p>
  <p>
  <input type="Button" name="Submit" id="mybut" value="Submit" onclick="show_filename()" />
  </p>
</form>
</body>

推荐答案

在函数中提及值名称属性.
mention the value name property in the function.
function show_filename()
{
var filename = document.getElementById(''text1'').value;
alert(filename);
}


输入类型为文件.
您的回答在文本框中是可以的,但是输入type =''file''
Input type is file.
your answer is OK with textbox but What about input type=''file''



我想我找到了你的问题,
我刚出了一个html文件(输入)控件和一个html按钮进行提交,比我尝试在IE上运行它更有效,但是当我尝试在mozilla firefox上运行它时却不起作用,因为文件控件名称和ID标记必须相同.
这也是我的代码块,也可以在mozilla firefox上工作;




函数show_filename(){
var filename = document.getElementById(''fileupload'').value;警报(文件名);
< script/>

//我的控件
< body>
< div>
< input id ="fileupload" name ="fileupload" type ="file"/>< br/>
< input id ="button1" type ="button" value ="button" onclick ="show_filename();" />
</div>
</body>



注意:重点是文件控件的名称和ID必须相同.
注意2:如果要查找代码问题,可以将firebug用于firefox,可以从firebug的控制台中观看JavaScript.
祝你好运.
Hi,
I think I found your problem,
I just out a html file(input) control and a html button for submit ,than I tried to run it on IE ,it worked but when I tried to run it on mozilla firefox it didn''t work because file control''s name and id tags must be same .
this is my code block that is working on mozilla firefox too;




function show_filename() {
var filename=document.getElementById(''fileupload'').value; alert(filename);
<script/>

// my controls
<body>
<div>
<input id="fileupload" name="fileupload" type="file"/><br/>
<input id="button1" type="button" value="button" onclick="show_filename();" />
</div>
</body>



note: the important point is file control''s name and id must be same.
note 2: if you want to find what''s the problem with code , you can use firebug for firefox , you can watch your javascript from firebug''s console.
Good luck.


这篇关于如何从文件控制中获取完整路径???的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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