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
dev_forcedev_force 

Can inputFile be used with a different standardController ?

The documentation has the example

<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>

 

 

 

Is it possible to use the inputFile tag with another controller? For example:

 

 

<apex:page standardController="Some_Custom_Object__c" 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>

 

 

Thanks.

jwetzlerjwetzler

What are you attempting to do?

 

InputFile must be bound to a blob in apex or a blob field type.  The reason the example uses the standard controller on document is so it can bind directly to the document.body.

 

You can use inputFile with any type of controller/standardController/extension that you want, but ultimately the value has to be bound to a Blob.