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
Joe HayesJoe Hayes 

inputFile causing unauthorized error on sites page

I have a site that I want to use to upload files to users accounts.

I already have the site up and running and it can push data into salesforce and create records.

I am now trying to use an <apex:inputFile> in the page so users can upload files to the account.

When I add this and then call my upload method I get an unauthorized message. I have checked permissions and cannot find anything relating to attachments. I have ticked the "Allow site guest users to upload files" box.

Code is as follows:

Page (I have removed other fields, images etc but nothing that affects this issue)
<apex:page sidebar="false" showHeader="false" applyBodyTag="false" applyHtmlTag="false" standardStyleSheets="false" controller="CustomPortalController">
      <td>Please attach PO here: </td>
      <td><apex:inputfile value="{!poBlob}" filename="PO.pdf"/></td>
      <td><apex:commandbutton action="{!insertAttachment}" value="Confirm Booking" oncomplete="trainingConf();"></apex:commandbutton>

Controller (Other things happen in this controller that I have removed but don't affect this issue)
public class CustomPortalController {

    public Attachment attach {get;set;}
    public transient Blob poBlob {get; set;}

public PageReference insertAttachment(){
    String oppId = ApexPages.currentPage().getParameters().get('id'); 
    attach.parentId = oppId; = 'POName.pdf';
    attach.body = poBlob;
    insert attach;
    return null;


simply buzzes 9simply buzzes 9
your calcolation is awesom but could you please have a look on my site  ( and recommend me the best setting to find the best solution. Many Thanks