File upload using zk 5.0.5

I am trying to upload jar file using zk(5.0.5). While uploading i have checked its format (extension) for that I have used getFormat() API of the Media (


browsebtn.addEventListener("onUpload",new EventListener() {             
public void onEvent(Event event) throws Exception {
                private Media uploadedMedia;
                uploadEvent=(UploadEvent) event;
                    String fileName=uploadedMedia.getName();
                    System.out.println("File Format Name"+fileFormat);

Problem is that for internet explorer i get format as zip , for chrome and Firefox i get its format as octet-stream . Why there is such mismatching for different browsers . How to solve this problem ?(I dont want to any hard coding such as browser check)


You can try with;

LobData data = ZkUtils.media2LobData(uploadedMedia);

Then use that data:


I think the best way is to check the mime type to get the type, format, extension... of your file and to prevent some security attacks, for example you can use this :

File f = new File("test.pdf");
    System.out.println("Mime Type  of " + f.getName() + " is " +
                         new MimetypesFileTypeMap().getContentType(f));
    // "Mime Type of test.pdf is application/pdf"

You can find here the list of the most popular mime types.

Hope this helps.

Need Your Help

Apache .htaccess to hide both .php and .html extentions

apache .htaccess mod-rewrite url-rewriting rewrite

What lines should I add to remove both .html and .php extensions from my site?