0

How to limit the file types to be uploaded

asked 2008-08-09 12:41:25 +0800

okgago gravatar image okgago
99

Hello,

Is there a way to limit the file types to be uploaded by the FileUpload component?

For instance if I want only image files to be uploaded, in the file upload dialog, the user will only be able to select image files (gif, jped, png, etc.)! Nothing else.

For example, there may be a property of the fileupload component such as:

<fileupload contentType="image" />
<fileupload contentType="*.gif" />
<fileupload contentType="*.gif,*.jpeg" />


So that I won't need to check the content type of the file the user uploaded -in the onUpload event.

Thanks

delete flag offensive retag edit

4 Replies

Sort by ยป oldest newest

answered 2008-08-09 15:00:38 +0800

natnan gravatar image natnan
27

you can check zkdemo from http://www.zkoss.org/zkdemo/userguide/
in the left frame select Fileupload,then click on the try me button.
there,you will see how it can be done.

link publish delete flag offensive edit

answered 2008-08-09 15:19:34 +0800

okgago gravatar image okgago
99

Hi natnan,

Sure you can check the type after uploading the file, but as I said in my previous post, I don't want to do that. That point is too late!

What I want is to prevent the user from even selecting a file of a type (in the file upload dialog) which is different than the one I specify.

link publish delete flag offensive edit

answered 2008-08-11 04:23:38 +0800

dennis gravatar image dennis
3679 1 6
http://www.javaworld.com....

There is an attribute 'accecpt' which defined the content type of HTML 'input' tag when type is 'file',
but no famous browser implement it for now, and cause of this restriction ZK hard to implement this feature.

link publish delete flag offensive edit
link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2008-08-09 12:41:25 +0800

Seen: 424 times

Last updated: Mar 03 '14

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More