+ Start a Discussion
zeezackzeezack 

File Uploads

Hello,

I have created a web form that will allow users to insert new accounts and then attach new claims with them. So it inserts into the database the people account and then takes their unique id and attachs it to a new claim.

 

 

I now need to attach documents to each claim... is there a specific folder I can upload to, a temp folder then rename folder.

 

Does anyone here have any experience with this?

Best Answer chosen by Admin (Salesforce Developers) 
Ron HessRon Hess
they are added and stored as a b64 binary blob.  the soap API will allow you to create() an attachment , you pass in the base64 blob in the body field.

All Answers

zeezackzeezack
Am I right in thinking we import the file into the body field of attachment? In some kind of hex code version?
Ron HessRon Hess

here is the example from the doc

 

 

<; Page: --> <apex:page standardController="Document" extensions="documentExt"> <-- Upload a file and put it in your personal documents folder--> <apex:messages /> <apex:form id="theForm"> <apex:pageBlock> <apex:pageBlockSection> <apex:inputFile value="{!document.body}" filename="{!document.name}"/> <apex:commandButton value="save" action="{!save}"/> </apex:pageBlockSection> </apex:pageBlock> </apex:form> </apex:page> /*** Controller ***/ public class documentExt { public documentExt(ApexPages.StandardController controller) { Document d = (Document) controller.getRecord(); d.folderid = UserInfo.getUserId(); //this puts it in My Personal Documents } }

 

 

 

The page should bind the input file to the body of a document or attachment.  Your controller can create the attachment and then expose the attachment , then bind the input file to attachment.body .

 

you don't have to worry about the mime types or base 64 coding as this is done by the component.

 

 

zeezackzeezack

Hello Ron,

I am building this in php. This is not an attachment to the salesforce api. I've got the form to upload a file, but usually I've only delt with uploading files...from what I can tell here, it stores the file in the database...as a binary file?

zeezackzeezack
How is salesforce adding attachments?
SteveAnderson41SteveAnderson41
Since you are doing this with PHP, not Visualforce, maybe you should ask your question on the PHP board?
Ron HessRon Hess
they are added and stored as a b64 binary blob.  the soap API will allow you to create() an attachment , you pass in the base64 blob in the body field.
This was selected as the best answer