function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
hegde_hegdekhegde_hegdek 

How to store attachments using APEX

Hello Friends,

How do i store attachments using APEX,i am using the tag inputfile in visual force,but against

which object type do i store it against.

regards

hegde_hegdek

sfdcfoxsfdcfox

Use "Document" if you want to store files in the document tab, and use "Attachment" if you want to store files attached to a record; use ParentId to specify which record the attachment is stored against. Please note that it is important to capture the Name, Body and ContentType values or your document may not store correctly or be rendered correctly by a browser when re-downloaded.

dmsx2oddmsx2od

See the documentation for apex:inputfile - it shows how to use documents.

Or try http://salesforcecode.com/apex/uploading-a-file-as-a-document-using-visualforce to use inputfile with a Visualforce component.