Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <apex:repeat value="{!newAttachments}" var="newAtt">
- <apex:outputLabel value="Upload file"/>
- <apex:inputFile id="inputfile" value="{!newAtt.body}" filename="{!newAtt.name}" onchange="checkFileSize(event)" />
- </apex:repeat>
- <script>
- function checkFileSize(event){
- if ($("[id$=inputfile]")[0].files.length > 0) {
- //validate file attachment is not > 500k
- var uploadFileSize = $("[id$=inputfile]")[0].files[0].size;
- if (uploadFileSize > 1024 * 1024 * .5) {
- alert('File uploads must be less than 500k in size. remove files over: '+(Math.round(uploadFileSize/1024)) + 'k');
- event.preventDefault();
- }
- else {
- //
- }
- }
- else {
- // no file attached, if not required, call save method
- }
- }
- </script>
Add Comment
Please, Sign In to add comment