0

I try write custom validator for liferay to valid file size before upload.But i cant get file size from fieldNode.

Here is print fieldNode:

+++fieldNode:fieldNode:INPUT#_31_WAR_uploadportlet_avatarUpload yui_patched_v3_11_0_1_1510909953942_944 

And here print selector use document.getElementById:

+++selector:[object HTMLInputElement]

This selector not problem with get file size.

So what diffrent between fieldNode and normal selector ? And how get file size from fieldNode.

This important for write custom validator can reusable. Please help me.

Jin
  • 67
  • 11

1 Answers1

0

You can do the same as the jQuery example shows. If you have the AUI node just do

fieldNode._node.files[0].size
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Miroslav Ligas
  • 1,287
  • 8
  • 22
  • I think validate, show message and prevent before user upload a file too big is good way with user experience. – Jin Nov 25 '17 at 10:17