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

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.




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.


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

Or try to use inputfile with a Visualforce component.