daily pastebin goal
43%
SHARE
TWEET

Untitled

a guest Dec 19th, 2018 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top