Guest User

Untitled

a guest
Dec 19th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. <apex:repeat value="{!newAttachments}" var="newAtt">
  2. <apex:outputLabel value="Upload file"/>
  3. <apex:inputFile id="inputfile" value="{!newAtt.body}" filename="{!newAtt.name}" onchange="checkFileSize(event)" />
  4. </apex:repeat>
  5.  
  6. <script>
  7. function checkFileSize(event){
  8. if ($("[id$=inputfile]")[0].files.length > 0) {
  9. //validate file attachment is not > 500k
  10. var uploadFileSize = $("[id$=inputfile]")[0].files[0].size;
  11. if (uploadFileSize > 1024 * 1024 * .5) {
  12. alert('File uploads must be less than 500k in size. remove files over: '+(Math.round(uploadFileSize/1024)) + 'k');
  13. event.preventDefault();
  14. }
  15. else {
  16. //
  17. }
  18. }
  19. else {
  20. // no file attached, if not required, call save method
  21. }
  22. }
  23. </script>
Add Comment
Please, Sign In to add comment