How can I avoid this error? I read similar post without getting any working solutions for me. When I try to upload file larger than about 150k, I get the error.

 <apex:page controller="FormCurriculumController" showHeader="false">


 function show() {



<style type="text/css">
body { background-color:#FFF; }
.erroreMsg, .required { color:#F00; }

<apex:form styleClass="wwwtesto" rendered="{!NOT(saved)}">
    <p>Fields marked with an * are mandatory.</p>
    <apex:messages styleClass="required" />
        <apex:outputLabel value="First name *" for="firstName"/>
        <apex:inputField id="firstName" required="true" value="{!curriculum.FirstName__c}"/>
        <apex:outputLabel value="Last name *" for="lastName"/>
        <apex:inputField id="lastName" required="true" value="{!curriculum.LastName__c}"/>
        <apex:outputLabel value="Email *" for="email"/>
        <apex:inputField id="email" required="true" value="{!curriculum.Email__c}"/>
        <apex:outputLabel value="Message" for="note"/>
        <apex:inputField id="note" required="false" value="{!curriculum.Note__c}"/>
        <apex:outputLabel value="Attachment" for="resume"/>
        <apex:inputFile id="resume" fileName="{!fileName}" contentType="{!contentType}" value="{!resume}" size="45"/>
    <apex:inputCheckbox id="privacy" required="true" value="{!privacy}"/>I authorise the use of my personal data in compliance with Legislative Decree 196/03.
    <p><apex:commandButton value="Send" action="{!save}" onclick="show()"/></p> 
    <div id="myDiv" style="display:none;"><apex:image value="{!$Resource.Loader}"/></div>
  <apex:outputText styleClass="wwwtesto" rendered="{!saved}" value="Thank you for submitting your resume."/>



public class FormCurriculumController { 
public Curriculum__c curriculum {get; set;}
public Boolean privacy {get; set;}
public Boolean saved {get; set;}
public String styleClass {get; set;}
// Allegato
public Blob resume {get; set;}
public String contentType {get; set;}
public String fileName {get; set;}

public FormCurriculumController () {
    curriculum = new Curriculum__c();
    saved = false;

public PageReference save() {
    try {
        // Validazione effettuata qui perchè il required sull'inputCheckbox non è utilizzabile
        if (!privacy) {
            ApexPages.Message reqMsg = new ApexPages.Message(ApexPages.Severity.ERROR, 'Autorizzare il trattamento dei dati personali');
            return null;

        // Inserisce il record
        // Inserisce l'allegato
        if (resume != null) {
            Attachment attach = new Attachment();
            attach.Body = resume;
            attach.Name = fileName;
            attach.ContentType= contentType;
            attach.ParentId = curriculum.id;                
            try {

            } catch (Exception ex) {
                // TODO fare il roolback dell'inserimento del curriculum?

                return null;

        //Papagni 03/09/2013 - update curriculum per fare scattare il trigger di after che invia la mail
        update curriculum;

        saved = true;

    catch(Exception ex) {
    return null;   



  • 4
    Did you try making resume transient to keep it out of the view state? i.e. public Transient Blob resume {get; set;}
    – BarCotter
    Commented Oct 13, 2014 at 10:40
  • fine, it works!
    – user9959
    Commented Oct 13, 2014 at 10:42

2 Answers 2


The View State will most likely be caused by this tag because resume could be a rather large Blob.

    <apex:inputFile id="resume" fileName="{!fileName}" contentType="{!contentType}" value="{!resume}" size="45"/>

You don't need to store resume in the View State. You can use the Transient Keyword to make sure its not included in the View State. If you change your declaration of resume to what is shown below then it should stop your issue:

public Transient Blob resume {get; set;}

From sfdcfox's answer:

Transient variables are not stored in the view state, but can be regenerated by the post back if bound to an input element. In general, you only need to use the view state for elements not bound to an input element and need to maintain state between post backs.


It is enough to set resume = null;, empty fields are not going in viewstate.

  • 1
    @martin well, I had the same issue as asker, and this solution worked for me. So this is possible way of avoiding asker's issue. Commented Dec 13, 2015 at 11:03
  • My apologies, I misread your answer.
    – martin
    Commented Dec 14, 2015 at 1:30

You must log in to answer this question.