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

File Path missing in IMPUTFILE

We have a Visualforce page that is used to upload multiple images. The problem is that to validate, if it shows any errors, the page loses all of the images path.

I understand that safety is a value that is not retained. Anyone know a way I do not miss the path?

When you are using input file tag , you cannot rerender the page. If you are using refresh mechanism it wont work.
Ranu JainRanu Jain

Can you please provide your code?



This is my code VF:

<apex:page controller="GRP_MultiImagenes" action="{!constructor}">
  <apex:form >
  <apex:pageMessages id="errors" />
    <apex:pageBlock title="LOAD IMAGES" mode="edit">    
      <apex:repeat value="{!relatedListFile}" var="rel">
        <table width="100%" border="0" cellpadding="0" cellspacing="0">
            <td>&nbsp;</td><td colspan="3"><apex:outputLabel value=" Imagen:"/></td>
            <td>&nbsp;</td><td width="300"><apex:inputFile value="{!rel.file}" filename="{!}" fileSize="{!rel.size}"/></td>
            <td width="300"><apex:outputLabel for="postFileId" value="Etiqueta : "/><apex:inputtext value="{!}" /></td>
        <br />
      <table width="100%" border="0" cellpadding="0" cellspacing="0">
          <td width="350"><apex:commandlink value="Show 3 rows more" action="{!addMore}"/></td>
            <apex:commandButton value="Save" action="{!syncFilesystemDoc}"/>
            <apex:commandbutton value="Cancel" action="{!Cancel}"/>

    <apex:pageBlock >
      <table width="100%" border="0" cellpadding="0" cellspacing="0">
          <apex:outputPanel id="uploadObjectRender" >
             <apex:actionstatus id="statusForUploadObject">
               <apex:facet name="start">
                 <span style="font-weight:bold; color: red; background-color:white;">&nbsp;&nbsp;&nbsp;Conectando a Amazon S3..........&nbsp;&nbsp;&nbsp;</span>
               <apex:facet name="stop">
                 <apex:outputPanel rendered="{!(AND(!ISNULL(uploadObjectErrorMsg),uploadObjectErrorMsg!='Success'))}" style="font-weight:bold; color: red; background-color:white;">
                   &nbsp;&nbsp;&nbsp;ERROR: {!uploadObjectErrorMsg}
             <apex:outputPanel rendered="{!(AND(!ISNULL(uploadObjectErrorMsg),uploadObjectErrorMsg=='Success'))}" style="font-weight:bold; color:green; background-color:white;">&nbsp;&nbsp;&nbsp;Imagen cargada. Si desea puede cargar otra.

This is APEX code:

public class GRP_MultiImagenes{

  //Variables fichero
    public String uploadObjectErrorMsg {get;set;}
    public String deleteObjectErrorMsg {get;set;}
    public String listBucketErrorMsg {get;set;}
  //Variables S3
     public String bucketToUploadObject;
     public String accessTypeSelected;
     public String OwnerId {get;set;}
  //Variables Force
     public Id sCaId {get; set;}
     public List<RelatedListWrapper> relatedListFile =new List<RelatedListWrapper>();
     public List<RelatedListWrapper> getrelatedListFile(){   
       if(relatedListFile.size() == 0){
         relatedListFile = new List<RelatedListWrapper>();
         relatedListFile.add(new RelatedListWrapper(null, null));
         relatedListFile.add(new RelatedListWrapper(null, null));
         relatedListFile.add(new RelatedListWrapper(null, null));
      return relatedListFile ;
    public class RelatedListWrapper{
        public String  Name {get;set;}
        public Integer Size {get;set;}
        public Blob    File {get;set;}
        public RelatedListWrapper(String s, Integer si,Integer i, Boolean b, Blob Bl){
        system.debug('*** RelatedListWrapper');
            this.Name = s;
            this.Size = si;
            this.File = bl;
  public GRP_MultiImagenes(){}
  public PageReference constructor(){
       sCaId = ApexPages.currentPage().getParameters().get('Campaign');
      return null;
  public pageReference syncFilesystemDoc(){
       system.debug('***** SAVE *****');
       List<GRP_MultiImagenes__c> toInsertMI = new List<GRP_MultiImagenes__c>();
       string IdS3;
       Boolean putObjResult;
       Boolean vError=false;      
       for (RelatedListWrapper relatedListFile : relatedListFile){
         if(relatedListFile.file != null){
           if(relatedListFile.file != null && == '') vError=true;


uploadObjectErrorMsg = 'ERROR';
         return null;

       for (RelatedListWrapper relatedListFile : relatedListFile) {

           if (!=''){

               Datetime now =;
               IdS3 =;
             //Recogemos la ruta y lo transformamos a base64.
               String docBody = EncodingUtil.base64Encode(relatedListFile.file);

             //Si la respuesta es optima añadimos el registro a Force.
                 toInsertMi.add(new GRP_MultiImagenes__c(Id_Amazon__c=IdS3,campaign__c=scaId,,orden__c=relatedListFile.orden,FileSize__c=relatedListFile.size,Imagen_principal__c=relatedListFile.principal));
       //Creo los registros en Force. Los q únicamente se han creado en
         Insert toInsertMI;
       // Envía al usuario al detalle de la página del sobject
         return new PageReference('/' + sCaId);
     }catch(System.CalloutException callout){
       System.debug('CALLOUT EXCEPTION: ' + callout);
       uploadObjectErrorMsg =    callout.getMessage();
       return null;
     }catch(Exception ex){
       System.debug('EXCEPTION: ' + ex);
       uploadObjectErrorMsg =  ex.getMessage();
       return null;
  public pagereference Cancel(){
     return new PageReference('/' + sCaId);
  public void addMore(){
        // append NUM_ATTACHMENTS_TO_ADD to the new attachments list
        integer ord = relatedListFile.size()+1;
        for (Integer idx=0; idx<3; idx++){
            relatedListFile.add(new RelatedListWrapper(null, null,ord+idx,false,null));


Use the above link and you can make the changes . It works great . Good one from Bob....