使用JSP和Java Servlet的图像上传器 [英] Image Uploader Using JSP and Java Servlet

查看:108
本文介绍了使用JSP和Java Servlet的图像上传器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Linux中
我想获取输入文件的位置,但只能获取图像的名称

JSP

In Linux
I want to get the location of an input file but I can only get the name of the image

JSP

<form action="Uploader" method="post">
   <input type="file" name="imageFile" />
   <input type="submit" value="Upload" />
</form>



(示例文件的位置为C:\ Program Files \ AVG \ AVG9 \ image.gif)

Servlet



(Example the location of the file is C:\Program Files\AVG\AVG9\image.gif)

Servlet

String path = request.getParameter("imageFile");
System.out.println(path);



当我打印路径时,它仅显示文件名image.gif



When I print the path it only display the name of the file which is image.gif

推荐答案

首先,您的表单必须为多部分,第二次尝试不使用apache上传文件就辛苦了! http://commons.apache.org/fileupload/ ^ _ ^
first your form need be multi-parts, second try to use apache upload file for not do a hard work! http://commons.apache.org/fileupload/ ^_^


这篇关于使用JSP和Java Servlet的图像上传器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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