Friday 24 March 2017

How upload large file in salesforce

Arpit Sharma

In Salesforce when we upload file using remote action then we are not able upload file more then 4.3 MB because above 4,3 MB we getting input too long I found one solution in which we are able to upload file upto 25 MB In this approach we are using sforce api on visual force page to upload file on salesforce.below is code of uploading file upto 25 MB.

  1. <apex:page>
  2. <script type="text/javascript">
  3. var __sfdcSessionId = '{!GETSESSIONID()}';
  4. </script>
  5. <script src="/soap/ajax/34.0/connection.js" type="text/javascript"></script>
  6. <script>
  7. function uploadAttachmentFromVisualForcePage() {
  8. var reader = new FileReader();
  9. var attachFile = document.getElementById('idOfUploadInputFileElement').files[0];
  10. if (attachFile == undefined) {
  11. alert('Please select a file');
  12. return;
  13. }
  14. if (attachFile.size > 26214400) { //Where 26214400 is byte equivalent of 25MB
  15. alert('Attachment size not supported');
  16. }
  17. reader.onload = function(e) {
  18. var attachment = new sforce.SObject('Attachment');
  19. attachment.Name =;
  20. attachment.IsPrivate = false;
  21. attachment.ContentType = attachFile.type;
  22. attachment.Body = (new sforce.Base64Binary(;;
  23. attachment.Description =;
  24. attachment.ParentId = 'recordID'; //Where recordID is the ID of record to which you want to add your attachment
  25. var result = sforce.connection.create([attachment]);
  26. if (result[0].getBoolean("success")) {
  27. alert('file uploaded successfully');
  28. } else {
  29. alert('something went wrong.');
  30. }
  31. };
  32. reader.readAsBinaryString(attachFile);
  33. }
  34. </script>
  35. <input type="file" id="idOfUploadInputFileElement" /><input type="button" value="Upload" onClick="uploadAttachmentFromVisualForcePage();" />
  36. </apex:page>

About the Author

Arpit Sharma / Author & Editor

Certified Salesforce Developer | Salesforce Developer at Cognizant | Blogger


  1. The main purpose for its success was the desk bitcoin transaction system since bitcoin was booming, and people people|and folks} had been desperate to get their palms on it. It is greatest and most fun to play real money pokies to win real cash prizes. All of those pokies have 5 reels, free spins, scatter and wild symbols, and bonus rounds besides Triple Diamond, which is a traditional 솔카지노 one with three. In Australia, playing is regulated by the federal government, and on-line casinos are required to provide them with the data they need. Bally Slots — A provider most well-known for 88 Fortunes, Quick Hit, Dragon Spin, Cash Wizard, Michael Jackson. They additionally give players free of charge spins starter packs for some on-line pokies.

  2. Looking for an thrilling method to spend a weekend or a staycation close to residence in central California’s San Joaquin Valley? When it comes to slot machine casinos with new slot machine games in California, Tachi Palace Casino Resort has everything you could ask for. As a luxury resort resort and slot machine casino positioned in Lemoore, we offer a variety of|quite lots of|a wide selection of} stimulating games in a vivacious setting that may take up you during your keep. Located on the 3rd floor of the Casino, the High Limit Room contains each guest-favorite machines at larger denominations, nicely as|in 1xbet korea addition to} exclusive new games.