以下是我上传所提交的action,为什么在本地机器上测式是好的,但把程序放到外网就不行了,外网日志下面的话都能打出来!
提示上传成功,但就是没有文件传进来!
public ActionForward upload(ActionMapping arg0, ActionForm arg1,
HttpServletRequest arg2, HttpServletResponse arg3){
try
{
FormFile formfile = (FormFile) ((DynaActionForm) arg1).get("file");
System.out.print("the value of the formfile is:"+formfile.getFileSize());
InputStream input=formfile.getInputStream();
//下面的这名话就是获得资源文件中的一个配置路径
String path=getConfigParameterValue("sitemapdirectory")+"/";
System.out.print("把路径拼到具体的目录下,路径的值为"+path);
OutputStream stream=new FileOutputStream(path+formfile.getFileName());
System.out.print("文件的名称为:"+formfile.getFileName());
File file=new File(path+formfile.getFileName());
System.out.print("上传文件所在的具体路径为"+path+formfile.getFileName());
if(file.exists())
{
file.delete();
}
int readdata=0;
byte []data=new byte[1024];
//当读到最后一行时会返回-1
System.out.print("开始写入文件...");
while((readdata=input.read(data))!=-1)
{
System.out.print("write"+readdata);
stream.write(data,0,readdata);
}
System.out.print("文件写入完毕");
response.getWriter().write("alert('上传成功')");
response.getWriter().write("window.history.back()");
input.close();
stream.close();
System.out.print("流关闭成功");
}catch(Exception ex)
{
try {
response.getWriter().write("alert('上传失败')");
response.getWriter().write("window.history.back()");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return null;
}
[b]问题补充:[/b]
路径应该没什么问题,因为在日志上能够输出上面的测式内容,而且日志还没有报错,比如说
FILENOTFOUNT这些异常都没有,非常正常的把我想测式的话打出来了!(包括文件上传的路径都是对的) 苦恼!这个问题搞了两天了!
对了!服务器用的linux系统,会不会有什么影响!
[b]问题补充:[/b]
恩!你想的很全面!这个问题,我们经理把包的访问权限调到最低了!还是不行!