Skip to main content link. Accesskey S

The useful resource for IBM Lotus Domino XPages development

Submit Search


Home > UI > Work with a file upload and download controls
xpageswiki.com
is maintained by 
Julian Buss.
You can hire me.

Work with a file upload and download controls

ShowTable of Contents

Restrict the size of uploaded files


Set in Application Properties -> XPage Properties -> File Upload max size .

Limiting file types for upload


You can set define which file types are allowed to be uploaded in the upload control -> all properties -> basics -> accept.

Read details in Domino Designer Wiki.

How to process an uploaded file


Place code like this in the beforeRenderResponse event of an XPage to get a handle to a just-uploaded file:

var con = facesContext.getExternalContext(); 
var request:com.sun.faces.context.MyHttpServletRequestWrapper = con.getRequest(); 
var map:java.util.Map = request.getParameterMap(); 
var fileDataName = "file"; //name of the POST request parameter that contains the file 
var fileData:com.ibm.xsp.http.UploadedFile = map.get( fileDataName ); 
var tempFile:java.io.File = fileData.getServerFile();


The file is in the "xspupload" directory on the Domino Server and has some crypting filename. You can get the original filename with fileData.getClientFileName().

For example, you can attach the file to some Notes document with code like this:

var correctedFile = new java.io.File( tempFile.getParentFile().getAbsolutePath() + java.io.File.separator + fileData.getClientFileName() ); 
var success = tempFile.renameTo(correctedFile); //rtFiles is a rich text item on a notesdocument of your chosing rtFiles.embedObject(lotus.domino.local.EmbeddedObject.EMBED_ATTACHMENT, "", correctedFile.getAbsolutePath(), null); 
correctedFile.renameTo(tempFile);


This snippet renames the temporary file to the orginal filename, attaches it to a RichText item and renames it back to the cryptic name (so that it will be deleted by Domino after processing).

Found by Mark Leusink

How to enable large file uploads in Domino


Open the server document in the Domino Directory, go to Internet Protocols/HTTP and then to the "HTTP Protocol Limits" section.
Set the fields "Maximum size of request content" and "Maximum POST data" to the same value (for example 20.480 for a 20MB limit).
Then set this limit in your application in Application Properties -> XPage Properties -> File Upload max size.

Details at Declan Lynch
Created by Anonymous on Aug 27, 2009 2:50:55 PM

Hi, can you upload files with more than 1024 kb in all of my XPages I did not manage to to that.

Kind regards David


Created by Julian Buss on Sep 10, 2009 8:56:44 PM

I think so... but I tested that recently on Domino 8.5.1 (not available yet), I don't know how it's like in 8.5.0.

Check out the application properties -> xpages tab, there you can set a limit for uploaded files.


Created by Anonymous on Sep 17, 2009 12:40:36 PM

Is there a workaround to rename uploaded files?

Thank you in advance

Marco


Created by Anonymous on Sep 21, 2009 8:30:04 AM

I have not been able to increase the file download size either. I get an error page immediately after calling the saveDocument action with larger files.


Created by Julian Buss on Oct 12, 2009 9:48:51 AM

we'll have to check that with 8.5.1 again


Created by Julian Buss on Oct 12, 2009 9:49:13 AM

none I'm aware of, but I believe it works in 8.5.1


Created by Anonymous on Jan 2, 2010 2:34:04 PM

1024 is the default, set manually a larger value.

cdkeito


Created by Anonymous on Aug 26, 2010 8:11:02 AM

Hi.

I have 3 file upload control and one file download control in a xpage and bind it to a richtext field in a form , added a button with the simple action "Save Document" in xpage.

first I have uploaded 3 files and click the save button.

then I have deleted all the attachments using the delete option in file download control.and I clicked the same save button again.

then i am again uploading all the attachments and click the save button.

I am getting the error "Error while saving the document".......

can u help me with this.


Created by Anonymous on Aug 31, 2010 1:36:08 AM

Hi Julian, hope you can help.

I've set my app to allow 10 MB file uploads via Application Properties (8.5.1).

I've got my file upload control on a dijit.dialog & it creates a new doc w/attachment on save. I need to display an error msg to user if their upload fails/will fail because file is too large. I don't think using the standard display error control works too well because all validation needs to be client-side on the dijit.dialog (I can't remember, but that's what I've ended up with for the rest of my validation) & I don't want to have alert boxes for my errors. At any rate, I tried binding a display error control to the file upload control & it doesn't display any errors (even alerts) if the file's too big -- I get a IE Connection error page instead. Is the file size available client-side so I can code my own error validation? Or ???

Thank-you,

Judy.


Created by Anonymous on Dec 20, 2010 1:09:12 PM

Hi Julian,

Do you know if the bug in the download control are solved in varsion 8.5.2? I can“t get it to work... :-(


Created by Julian Buss on Dec 29, 2010 11:50:59 AM

yes, as far as I know it is resolved in 852.


Created by Anonymous on Jan 24, 2011 12:57:08 PM

hi.. is it possible to view the uploaded image file in the same page.. im try to find it, will u pls heip me to find that....


Created by Shruti on Feb 15, 2012 10:06:11 AM

I need to allow user to upload multiple attachement and Created On date should be the actual attachment creation date & time.

When I used file download control , it shows the first attachment attached date for all attachments.

Can anyone help?


Created by barry on Feb 28, 2012 2:33:11 PM

I am able to upload photo files and attach to my document. I just need to know how to be able to go back and view the documents and the attached photo files. Can anyone help?


Add Comment

Name:
Comments:
How to take your XPages App to the iPhone, iPad, Android: use Domino To Go!
Do you look for an XPages Workflow solution? Take YouAtNotes Workflow.