Attachments are different than documents and are only available for the following objects:
Account
Asset
Campaign
Case
Contact
Contract
Custom objects
EmailMessage
EmailTemplate
Event
Lead
Opportunity
Product2
Solution
Task
Salesforce.com restricts an attachment size to a maximum size of 5 MB. For a file attached to a Solution, the limit is 1.5MB. The maximum email attachment size is 3 MB. You can contact Salesforce.com support and possibly have them increase these limits. They should be able to increase the document and attachment size to 25MB. They cannot increase the limits for emails.
public with sharing class AttachmentUploadController {
public Attachment attachment {
get {
if (attachment == null)
attachment = new Attachment();
return attachment;
}
set;
}
public PageReference upload() {
attachment.OwnerId = UserInfo.getUserId();
attachment.ParentId = '0037000000lFxcw'; // the record the file is attached to
attachment.IsPrivate = true;
try {
insert attachment;
} catch (DMLException e) {
ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Error uploading attachment'));
return null;
} finally {
attachment = new Attachment();
}
ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO,'Attachment uploaded successfully'));
return null;
}
}
Please refer to the below links for more information: http://salesforcetrekbin.blogspot.in/2010/04/visualforce-file-upload-for-any-sobject.html http://blog.jeffdouglas.com/2010/04/28/uploading-an-attachment-using-visualforce-and-a-custom-controller/
Please mark my solution as the best answer if it helps you.
Attachments are different than documents and are only available for the following objects:
Account
Asset
Campaign
Case
Contact
Contract
Custom objects
EmailMessage
EmailTemplate
Event
Lead
Opportunity
Product2
Solution
Task
Salesforce.com restricts an attachment size to a maximum size of 5 MB. For a file attached to a Solution, the limit is 1.5MB. The maximum email attachment size is 3 MB. You can contact Salesforce.com support and possibly have them increase these limits. They should be able to increase the document and attachment size to 25MB. They cannot increase the limits for emails.
public with sharing class AttachmentUploadController {
public Attachment attachment {
get {
if (attachment == null)
attachment = new Attachment();
return attachment;
}
set;
}
public PageReference upload() {
attachment.OwnerId = UserInfo.getUserId();
attachment.ParentId = '0037000000lFxcw'; // the record the file is attached to
attachment.IsPrivate = true;
try {
insert attachment;
} catch (DMLException e) {
ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Error uploading attachment'));
return null;
} finally {
attachment = new Attachment();
}
ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO,'Attachment uploaded successfully'));
return null;
}
}
Please refer to the below links for more information: http://salesforcetrekbin.blogspot.in/2010/04/visualforce-file-upload-for-any-sobject.html http://blog.jeffdouglas.com/2010/04/28/uploading-an-attachment-using-visualforce-and-a-custom-controller/
Please mark my solution as the best answer if it helps you.
Attachments are different than documents and are only available for the following objects:
- Account
- Asset
- Campaign
- Case
- Contact
- Contract
- Custom objects
- EmailMessage
- EmailTemplate
- Event
- Lead
- Opportunity
- Product2
- Solution
- Task
Salesforce.com restricts an attachment size to a maximum size of 5 MB. For a file attached to a Solution, the limit is 1.5MB. The maximum email attachment size is 3 MB. You can contact Salesforce.com support and possibly have them increase these limits. They should be able to increase the document and attachment size to 25MB. They cannot increase the limits for emails.Example for Attachment from Visual Force Page:
Visual Force Page:
Apex Page;
Please refer to the below links for more information:
http://salesforcetrekbin.blogspot.in/2010/04/visualforce-file-upload-for-any-sobject.html
http://blog.jeffdouglas.com/2010/04/28/uploading-an-attachment-using-visualforce-and-a-custom-controller/
Please mark my solution as the best answer if it helps you.
Best Regards,
Nagendra.P
All Answers
Attachments are different than documents and are only available for the following objects:
- Account
- Asset
- Campaign
- Case
- Contact
- Contract
- Custom objects
- EmailMessage
- EmailTemplate
- Event
- Lead
- Opportunity
- Product2
- Solution
- Task
Salesforce.com restricts an attachment size to a maximum size of 5 MB. For a file attached to a Solution, the limit is 1.5MB. The maximum email attachment size is 3 MB. You can contact Salesforce.com support and possibly have them increase these limits. They should be able to increase the document and attachment size to 25MB. They cannot increase the limits for emails.Example for Attachment from Visual Force Page:
Visual Force Page:
Apex Page;
Please refer to the below links for more information:
http://salesforcetrekbin.blogspot.in/2010/04/visualforce-file-upload-for-any-sobject.html
http://blog.jeffdouglas.com/2010/04/28/uploading-an-attachment-using-visualforce-and-a-custom-controller/
Please mark my solution as the best answer if it helps you.
Best Regards,
Nagendra.P