aspose file tools*
The moose likes JSF and the fly likes Uploading files using MyFaces Tomahawk. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Uploading files using MyFaces Tomahawk." Watch "Uploading files using MyFaces Tomahawk." New topic
Author

Uploading files using MyFaces Tomahawk.

Miclea Paul Alexandru
Greenhorn

Joined: May 18, 2011
Posts: 7
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

Joined: May 18, 2011
Posts: 7
bump!
Milan Mendpara
Greenhorn

Joined: May 10, 2011
Posts: 7

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

Joined: May 18, 2011
Posts: 7
I actually went a different direction with my program, but yes, your solution works great, thanks!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Uploading files using MyFaces Tomahawk.