Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Uploading files using MyFaces Tomahawk.

 
Miclea Paul Alexandru
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So i have managed to upload a file to my database using MyFaces Tomahawk. Everything works except that i want to put a filter on it so that the only files that i can upload should be *.zip. I have no idea how to do this.... Any suggestions?
 
Miclea Paul Alexandru
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
bump!
 
Milan Mendpara
Greenhorn
Posts: 7
Java Netbeans IDE PHP
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
do something like this :

<t:inputFileUpload id="fileupload" value="#{uploadBean.ufile}" />

import org.apache.commons.io.FilenameUtils;
import org.apache.myfaces.custom.fileupload.UploadedFile;

public class UploadBean {
UploadedFile Ufile;

public String doUpload() {
String prefix = FilenameUtils.getBaseName(Ufile.getName()); // returns the file name
String suffix = FilenameUtils.getExtension(Ufile.getName()); // returns the extension

if(suffix.equals("zip")
// do your upload code
}
}

i hope it will work for you acoording to your requirement ....
 
Miclea Paul Alexandru
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I actually went a different direction with my program, but yes, your solution works great, thanks!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic