int count=0; // Initialization mySmartUpload.initialize(pageContext); // Upload mySmartUpload.upload(); // Select each file for (int i=0;i<mySmartUpload.getFiles().getCount();i++){ // Retreive the current file com.jspsmart.upload.File myFile = mySmartUpload.getFiles().getFile(i); // Save it only if this file exists if (!myFile.isMissing()) { // Save the files with its original names in a virtual path of the web server myFile.saveAs("/upload/" + myFile.getFileName()); // myFile.saveAs("/upload/" + myFile.getFileName(), mySmartUpload.SAVE_VIRTUAL); // sample with a physical path // myFile.saveAs("c:\\temp\\" + myFile.getFileName(), mySmartUpload.SAVE_PHYSICAL); // Display the properties of the current file out.println("FieldName = " + myFile.getFieldName() + "<BR>"); out.println("Size = " + myFile.getSize() + "<BR>"); out.println("FileName = " + myFile.getFileName() + "<BR>"); out.println("FileExt = " + myFile.getFileExt() + "<BR>"); out.println("FilePathName = " + myFile.getFilePathName() + "<BR>"); out.println("ContentType = " + myFile.getContentType() + "<BR>"); out.println("ContentDisp = " + myFile.getContentDisp() + "<BR>"); out.println("TypeMIME = " + myFile.getTypeMIME() + "<BR>"); out.println("SubTypeMIME = " + myFile.getSubTypeMIME() + "<BR>"); count ++; } } // Display the number of files which could be uploaded out.println("<BR>" + mySmartUpload.getFiles().getCount() + " files could be uploaded.<BR>"); // Display the number of files uploaded out.println(count + " file(s) uploaded."); %>
解决方法:新建/WEB-INF/lib目录,将jspsmartupload的class文件打包成jar文件,放到/WEB-INF/lib目录下,在Jbuilder中的config JDK中将jspsmartupload的jar文件包含在classpath中,即可
int count=0;
SmartUpload myup = new SmartUpload();
必须放在doPost()方法里面.你那样的话,会导致每次上传的都一样
用 smartUpload 只需要用其三个方法,非常简单, 用editplus 写JSP程序吧它有一个例子,真的很简单