Discussions
- General Development
- Schema Development
- Apex Code Development
- Visualforce Development
- Formulas & Validation Rules
- Security
- Mobile
- Force.com Sites & Site.com
- Chatter Development
- Java Development
- .NET Development
- Perl, PHP, Python & Ruby
- Desktop Integration
- APIs and Integrations
- Visual Workflow
- Apple, Mac and OS X
- VB and Office Development
- AppExchange Directory & Packaging
- Salesforce Labs & Open Source Projects
- Other Salesforce Applications
- Jobs Board
- Force.com Discussion Boards
- :
- Developer Boards for Force.com and Database.com
- :
- General Development
- :
- Case attachments populating from php code, but fil...
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Case attachment s populating from php code, but files truncated at 8kb
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
12-04-2012 04:06 PM
I am trying to attach files to Salesforce cases via php. The file information is coming across okay and the attachment is getting created, but the files themselves are getting truncated at 8kb. Also, this is development work that's pointing to a Salesforce sandbox instance. Code snippet is as follows:
$mySforceConnection = $sf->client;
$sAttachment= new stdClass;
$handle = fopen($filepath,'r+');
$file_content = fread($handle,filesize($filepath));
fclose($handle);
$encoded = chunk_split(base64_encode($file_content));
$sAttachment->Body = $encoded;
$sAttachment->Name = $filename;
$sAttachment->ParentId = $sf_caseid;
$response = $mySforceConnection->create(array($sAttachment),'A
Solved! Go to Solution.
Re: Case attachment s populating from php code, but files truncated at 8kb
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
12-05-2012 01:32 PM
Resolved this.
Using "stream_get_contents($handle)" instead of "fread($handle,filesize($filepath))" did the trick.
Reference: http://php.net/manual/en/function.fread.php

