我试过了,系统提示如下: java.lang.IllegalArgumentException: The path is not a physical path. at com.jspsmart.upload.SmartUpload.getPhysicalPath(SmartUpload.java:1125) at com.jspsmart.upload.File.saveAs(File.java:91) at _admins._upfile2__jsp._jspService(/admins/upfile2.jsp:24) at com.caucho.jsp.JavaPage.service(JavaPage.java:75) at com.caucho.jsp.Page.subservice(Page.java:506) at com.caucho.server.http.FilterChainPage.doFilter(FilterChainPage.java:182) at com.caucho.server.http.Invocation.service(Invocation.java:315) at com.caucho.server.http.CacheInvocation.service(CacheInvocation.java:135) at com.caucho.server.http.RunnerRequest.handleRequest(RunnerRequest.java:346) at com.caucho.server.http.RunnerRequest.handleConnection(RunnerRequest.java:274) at com.caucho.server.TcpConnection.run(TcpConnection.java:139) at java.lang.Thread.run(Thread.java:534)
String path="/inc/"+myFileName;
//将文件保存在服务器端
myFile.saveAs(path,mySmartUpload.SAVE_PHYSICAL);
/inc目录已经存在。
好的,我试试这个方法。
java.lang.IllegalArgumentException: The path is not a physical path.
at com.jspsmart.upload.SmartUpload.getPhysicalPath(SmartUpload.java:1125)
at com.jspsmart.upload.File.saveAs(File.java:91)
at _admins._upfile2__jsp._jspService(/admins/upfile2.jsp:24)
at com.caucho.jsp.JavaPage.service(JavaPage.java:75)
at com.caucho.jsp.Page.subservice(Page.java:506)
at com.caucho.server.http.FilterChainPage.doFilter(FilterChainPage.java:182)
at com.caucho.server.http.Invocation.service(Invocation.java:315)
at com.caucho.server.http.CacheInvocation.service(CacheInvocation.java:135)
at com.caucho.server.http.RunnerRequest.handleRequest(RunnerRequest.java:346)
at com.caucho.server.http.RunnerRequest.handleConnection(RunnerRequest.java:274)
at com.caucho.server.TcpConnection.run(TcpConnection.java:139)
at java.lang.Thread.run(Thread.java:534)
//将文件保存在服务器端
myFile.saveAs(path);
不过/inc/a.exe是linux的路径啊。
你是不是搞反了?
路径有问题
<%@ page language="java" import="java.sql.*,com.jspsmart.upload.*"%>
<jsp:useBean id="mySmartUpload" scope="page" class="com.jspsmart.upload.SmartUpload" />
<%
// Variables
int count=0;
// Initialization
mySmartUpload.initialize(pageContext);
mySmartUpload.setTotalMaxFileSize(550000);
// Upload
mySmartUpload.upload();
com.jspsmart.upload.File myFile = mySmartUpload.getFiles().getFile(0);
count = mySmartUpload.save("/inc"); String myFileName=myFile.getFileName();
String path="/inc/"+myFileName;
int Size = myFile.getSize();%>