日期:2014-05-20  浏览次数:20734 次

struts2 action上传文件失败
页面内容:<form name="myform" action="user.action" id="myform" method="post" enctype="multipart/form-data">
  <input type="file" id="patientFile" name = "patientFile" size = "20"/>
  <input name="btnImport" type="submit" value="导入" class="btn" onclick="impInfo()"/>

action代码:
public String doImport() {
String line = null;
try {
File f = new File(patientFile);
InputStreamReader read = new InputStreamReader(new FileInputStream(getPatientFile()),"utf-8");
BufferedReader reader=new BufferedReader(read);
impList=new ArrayList();
while (reader.read()>0) {
line=reader.readLine();
if(line!=null){
String[] args = line.split(",");
for(int i=0;i<args.length;i++) {
........................
后台报:
java.io.FileNotFoundException: C:\apache-tomcat-6.0.32\work\Catalina\localhost\emr\upload_2cc44c9_133c627e012__8000_00000014.tmp (系统找不到指定的文件。)

但是我在本机测试是可以的,只是让别人访问我的地址不行.别人选择他机器上的文件上传时候,我后天打印他机器上的路径是对的。只是他不在远程去找这个路径

------解决方案--------------------
我做的也是本机是可以的.其他机子访问就没试过了..
------解决方案--------------------
以下代码是我做上传的一个例子,你可以参照一下:

html代码:
HTML code

<input type="file" name="file" id="imgurl" style="border:1px solid #7F9DB9;"/>