Uploading Attachments to Salesforce using Javascript Remoting


ForceAdventure

This is part 3 of a 4 part series on Javascript Remoting in Salesforce
Part 1: Javascript Remoting in Salesforce: A Primer
Part 2: Form Submission in Salesforce using Javascript Remoting
Part 4: Concurrency Concerns with Asynchronous Javascript Remoting in Salesforce

One more task you might consider using Javascript Remoting for is uploading a file to Salesforce. Admittedly, using an apex:inputFile element that is bound to a variable in your controller is probably easier but you may have a scenario where you need to have granular control over how your page acts.

Benefits

  • More granular and responsive error handling (Know the file is too big before you try to upload it)
  • Keep track of upload status (you could create a progress bar for uploads if you wish)

Limitations

  • Considerably more complex
  • Hoops to jump through because of limits on the platform
    • Javascript Remoting maximum message size of 1 million characters…

View original post 223 more words