This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal



Mar 23, 2011, 8:31 PM
261 Posts

Re: Get filepath of uploaded file

  • Category: Other
  • Platform: All
  • Release: 8.5.2
  • Role: Developer
  • Tags: file upload,file path
  • Replies: 14
Hi Sayan,
 
Using the technique I described here

http://www.bleedyellow.com/blogs/m.leusink/entry/processing_files_uploaded_to_an_xpage?lang=en
 
you can get a handle on the uploaded file. You have to check if one of the properties of the uploaded file contains the full path, although I'm not sure that the clientside path is sent to the server at all. From what I remember, as a security measure, browsers only send the file name, not the path.
 
Mark
Mar 24, 2011, 6:45 AM
6 Posts
Re: Get filepath of uploaded file
Hi Mark,
 
Thanks a lot but I think I am a bit confused. Does your code give me data of a file that is already uploaded or to be uploaded?
 
Thanks,
Sayan

Mar 24, 2011, 8:11 AM
261 Posts
Re: Get filepath of uploaded file
Hi Sayan,
 
It gives you a handle to a file that was just uploaded to the server. You can use the code in (for instance) the beforeRenderResponse event of an XPage to process the file.
 
The handle is actual a reference to a temporary file in the <data dir>/xspupload folder of your server.

Mark
Mar 24, 2011, 10:52 PM
4 Posts
Re: Get filepath of uploaded file
Hi Mark,
 
I am also having problems getting a handle on the just uploaded file.

I've read you blog posting and I'm using the code you offered in the beforeRenderedResponse event
 I'm using an xp upload control that renames the file to "image.jpg" and it's bound to an RTF.
 
when I submit the xpage, I get the following error from the beforeRenderedResponse:
 
"HTTP JVM: com.ibm.xsp.exception.EvaluationExceptionEx: Error while executing JavaScript action expression"
 
Through print statements, I've tracked it down to the "var tempFile:java.io.File = fileData.getServerFile()" line.
 
 The Notes document gets created with the attachment just fine.  But I want to get a handle on the image.jpg to create a thumbnail.
 
any help you can provide would be very much appreciated.

Regards,
 
Dan
Mar 25, 2011, 12:19 PM
261 Posts
Re: Get filepath of uploaded file
Hi Dan,
 
Have you tried to disable the file renaming option? It might be that that's causing the problem.

Mark
Mar 25, 2011, 5:28 PM
4 Posts
Re: Get filepath of uploaded file
Mark,
 
Per your suggestion, I disable the file renaming option, but it did not affect my issue.  I've left it disable and ran a few more tests.
It appears that the fileData variable is not getting set

From the Console:
HTTP JVM: **** in beforeRenderResponse
HTTP JVM: **** Code Line 1:  var con = facesContext.getExternalContext
HTTP JVM: **** con is NOT null

HTTP JVM: **** Code Line 2: var request:com.sun.faces.context.MyHttpServletRequestWrapper = con.getRequest
HTTP JVM: **** request is NOT null

HTTP JVM: **** Code Line 3: var map:java.util.Map = request.getParameterMap
HTTP JVM: **** map is NOT null

HTTP JVM: **** Code Line 4: var fileDataName = "file"
HTTP JVM: **** fileDataName NOT null
HTTP JVM: **** fileDataName = file


HTTP JVM: **** Code Line  5:  var fileData:com.ibm.xsp.http.UploadedFile = map.get( fileDataName )
HTTP JVM: **** fileData IS null

HTTP JVM: **** Code Line  6: var tempFile:java.io.File = fileData.getServerFile
HTTP JVM: com.ibm.xsp.exception.EvaluationExceptionEx: Error while executing JavaScript action expression

Thank you for you time.
 
Regards,

Dan
dlarson@synerjetic.com
Mar 25, 2011, 7:56 PM
39 Posts
Re: Get filepath of uploaded file
If you just need the path in the file upload control, is there any reason why you aren't just doing it on the client side and then putting into a hidden text field so the server side can access it?
 
 
Mar 26, 2011, 7:43 AM
261 Posts
Re: Get filepath of uploaded file
The sample I've described in my blog post can be used to create an XPage that can handle files that are (HTTP) POSTed to it.

To post a file to such an XPage you'd need to create (for instance) a HTML page, containing a file upload, with the form method set to POST and the action to the location of the XPage.
 
It's probably possible to change the code so it can handle a file upload contained on it, but I haven't tested that. The could would probably have to be moved to the querySaveDocument event.
 
Mark

This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal