Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

jspsmartupload (the same to previous topic with source code)  RSS feed

 
Yurong Chen
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please help me to find out that why I cannot use the syntax uploadInFile()of SmartUpload class in Jspsmartupload package successfuly. I want to save the upload file into a specific path with a specific name.
In my sequenceTry.jsp file:the code is as followed:
<FORM METHOD="POST" ACTION="sortTry.jsp" ENCTYPE="multipart/form-data">
<P><B><FONT COLOR="#CC66FF" SIZE="3">Please upload your excel file here</FONT></B>
<INPUT TYPE="file" NAME="file" SIZE="60">
<INPUT TYPE="submit" NAME="submit" VALUE ="upload" SIZE="60">
<br><font color="red" size="-2<font></P></FORM>

In my sortTry.jsp file, the code is as followed:
<%
int fileSize =0;
String fileName="" ;
String filePathName="" ;
String uploadFileName="" ;
String queue ="";
......
try {

// Initialization
mySmartUpload.initialize(pageContext);
mySmartUpload.setAllowedFilesList("xls,");
mySmartUpload.setMaxFileSize(250000);

uploadFileName = "/home/m1yc3/context/matlab/" + "uploadFile"+queue+".xls";

mySmartUpload.uploadInFile(uploadFileName);
mySmartUpload.uploadInFile("/home/m1yc3/context/matlab/upload.xls");

com.jspsmart.upload.File myFile = mySmartUpload.getFiles().getFile(0);

fileSize = myFile.getSize();
fileName = myFile.getFileName();

filePathName = myFile.getFilePathName();
......}
catch (IOException e){
e.printStackTrace();
}
catch (SmartUploadException e){
e.printStackTrace();
}
%>
 
Andres Gonzalez
Ranch Hand
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Yurong.
first of all please try to use the CODE brackets (or whatever you call it) when you post your source code, it is easier to understand.
I am using jspsmartupload but I do not use uploadInFile. I use saveAs. Something like this:

I think it is the same you want to achieve. isn't it?
let me know if you have more problems
britt50423@yahoo.com
 
Yurong Chen
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Andres,
Thank you very much! I tried this syntax this morning and it works very well!
Thank you !
Yurong
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!