• Rémi BERTHON
  • NEWBIE
  • 0 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies

Can anyone clue me in on how to bring an attachment down from SF so my users can download to their machine?

 

I understand how to query or retrieve from the attachment object and also understand the need to decode the base64 encoded body, but my attempts have gone nowhere thus far.  Here is my code:

//SF Header stuff require_once ($_SERVER["DOCUMENT_ROOT"].'/system/header_sforce.php'); //Grab an Attachement Id from the reqeust object $attid = $_REQUEST['attid']; //Query SF for the desired attachment $query = 'SELECT Id, ParentId, Name, BodyLength, Body FROM Attachment WHERE Id = \''.$attid.'\' '; $queryObject = $mySforceConnection->query($query); //Probably have some header() methods here echo base64_decode($queryObject->records[0]->Body);

 

I know it's not elegant, right now I'm just trying to get a rudimentary download working.  If someone could just cut and paste an example of some working code from their app that would be so awesome.

 

Thanks in advance.