如何在浏览标记中设置默认位置 [英] how to set default location in browse tag

查看:66
本文介绍了如何在浏览标记中设置默认位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在j2ee中做项目.我使用浏览"按钮.我每次都需要从项目文件夹中的文件夹中获取图像/文件.我希望将项目的文件夹名称设置为浏览按钮的默认位置.如何实现?

Am doing project in j2ee.I use Browse button. I need to fetch images/files from a folder inside my project folder, everytime.I wish to set my project's folder name as a default location for my browse button.How to do that?

am在jsp页面中使用以下代码:

am using tis following code in a jsp page:

并在servlet中调用值:

and calling the value in servlet :

String image =(String)request.getParameter("img");

String image= (String) request.getParameter("img");

浏览时,将显示整个路径,但仅图像名称作为sevlet中的值传递.如何获取整个路径?或如何在浏览时将我的项目文件夹设置为默认位置?

while browsing ,the whole path is getting displayed but only the name of the image is passing as value in the sevlet.How to get the entire path? or how to set my project folder as default location while browsing?

推荐答案

我实际上用一个有趣的技巧解决了这个问题.这就是...

I actually solved this problem with an interesting trick. Here's how...

创建一个名为vbshelper.inc的外部vbscript include file,其中包含以下代码:

Create an external vbscript include file called vbshelper.inc which contains the following code:

function stuffKeys(x)
     Set wshShell = CreateObject("WScript.Shell")
    wshShell.Sendkeys(x)
end function


在您的HTML代码标题中,将以下行作为您的第一个>元素...


Inside your HTML code header, place the following line as your first < Script> element...

< Script type="text/VBScript src="vbshelper.inc">

稍后,在您的HTML代码中,像这样创建按钮...

later, in your HTML code, create the button like this...

< input type="File" id="srcFile" onchange="go_do_something()" onclick="stuffkeys(' C:\Temp\*.txt~')">

请注意' C:\Temp*.txt~'中C之前的空格和.txt之后的波浪号~.

Note the space before the C in ' C:\Temp*.txt~' and the tilde ~ after the .txt.

这篇关于如何在浏览标记中设置默认位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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