0

I am making a simple form using Alloy UI. It has an image upload field. I want to restrict image file size say, to less than 10MB.

I have tried <aui:validator name="min"> and <aui:validator name="max"> in my view.jsp.

But, this is not working.

What should be used here to restrict image file size?

Prakash K
  • 11,669
  • 6
  • 51
  • 109
Shruti
  • 47
  • 8
  • If you want good response for your question, you should paste your code and exceptions(if any)... – Vikas V Jan 02 '13 at 14:41

1 Answers1

0

It seems you want a validation of file size on the client side i.e. using Alloy UI javascript, so I am sorry to bring to your notice that this is not possible in pre-HTML5 browsers due to some security reasons but this is possible with browsers which support the File-API in HTML5. Here is a good-demo site for the file-API.

So for now I would suggest that you do this server-side as a fallback mechanism & there are different plugins available to help you do this using Ajax or just go with plain server-side validation.

You can also try using flash with alloy-ui to check file-size as liferay does in its Documents & Media portlet. The drawback with this approach is that it requires flash to be installed in your browser.

Here is a SO answer which may help you give more information about client-side validation alongwith a demo.

Hope this would give you some lead.

Community
  • 1
  • 1
Prakash K
  • 11,669
  • 6
  • 51
  • 109