6

I have a Force.com site to create cases for partner portal users. I want to add the attachment functionality to this page. I am getting the filenotfound exception as soon as i hit this page on sites.

<apex:outputText value="Attach Document" styleClass="lableText" style="margin: 7px 0px;"/><br/>
<apex:inputFile value="{!fileBody}" filename="{!attachment.name}" id="file" style="border: solid 1px #B1B1B1;margin: 7px 0px; width: 476px;"/><br/>
<apex:outputText value="Note: Max file size for upload is 5MB" style="margin-top: 10px;"/><br/>
<apex:outputText styleClass="inputText">
    Note – You will only be able to submit one file on the initial email submission. If you need to attach multiple files on the initial submission, please Zip files accordingly and attach the Zip file in the attach document field. If you try and attach multiple files without zipping them, only the last file selected will be in the attach document field. You will be able to submit multiple files without zipping them once you receive a reply from TE that your initial email request was received.
</apex:outputText>

attachment.ParentId = vcase.Id;
attachment.IsPrivate = false;
attachment.body = fileBody;

try {
    upsert attachment;
}

Please let me know what i am missing. Is it possible to insert the attachments from sites?

1
  • Yes, it's possible Commented Mar 5, 2013 at 3:43

1 Answer 1

8

I have no idea what you have fileBody originally set as, but you would be better off associating it as:

<apex:inputFile value="{!attachment.Body}" filename="{!attachment.Name}"/>

Also, I can definitely tell you it is possible to do it through Force.com Sites. I have done it before. You are just experiencing an exception due to malfunctioning code. I would also use insert on the attachment. The ID is never going to be set since they are creating a new attachment. There is no need to use upsert in this scenario.

1
  • I have replaced the filebody with the Attachment.body still i am getting the error APEX/FileNotFound. Commented Mar 5, 2013 at 5:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .