如何在浏览标签中设置默认位置

发布于 2024-07-10 13:10:26 字数 291 浏览 4 评论 0原文

我正在 j2ee 中做项目。我使用浏览按钮。 我每次都需要从项目文件夹内的文件夹中获取图像/文件。我希望将项目的文件夹名称设置为浏览按钮的默认位置。如何做到这一点?

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

并调用 servlet 中的值:

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

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

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 using tis following code in a jsp page:

and calling the value in servlet :

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

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

海拔太高太耀眼 2024-07-17 13:10:26

如果这是呈现标准,

<input type="file".../>

那么您无法控制默认目录。

使用 Flash 可以让您获得更多控制权(文件类型预设、单个/多个文件选择等)。

我不确定 Java Applet 是否有更多访问/选项,希望有人可以提供建议。

附言。 对于标准输入标签,浏览器会记住您上次使用的位置,因此如果您要从同一目录上传多个文件,则只需导航一次。

If this is rendering a standard

<input type="file".../>

Then you have no control over the default directory.

Using flash gains you a bit more control (filetype preset, single/multiple file selection etc.)

I'm not sure if Java Applets have more access/options, hopefully someone can advise.

PS. for the standard input tag, the browser will remember the last location you used, so you only need to navigate once, if you are uploading several files from the same directory.

抠脚大汉 2024-07-17 13:10:26

我实际上用一个有趣的技巧解决了这个问题。 方法如下...

创建一个名为 vbshel​​per.inc 的外部 vbscript 包含文件,其中包含以下代码:

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

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

<代码>< Script type="text/VBScript src="vbshel​​per.inc">

稍后,在您的 HTML 代码中,创建如下按钮...

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

注意 ' C:\Temp*.txt 中 C 之前的空格~' 和 .txt 后面的波形符 ~

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

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

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

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

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

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

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文