on 05-05-2005 12:06 AM
The following does not seem to find a valid file to upload and isFileParam always returns false. I am using AbstractPortalComponent and the example sin SDN seem to use PageProcessorComponent.
myContext =
PageContextFactory.createPageContext(request, response);
Event lastEvent = myContext.getCurrentEvent();
if (lastEvent != null) {
if (lastEvent.getComponentName().equals("submit")) {
if (myContext.isFileParam("fileUpload"))
response.write("yep, it's a file parameter");
else
response.write("not a file param");
//
//
//
FileUpload file = new FileUpload("fileUpload");
file.setAccept("text/xml");
file.setSize(50);
Label label = new Label("Select XML file with assignments");
gl.addComponent(1, 1, label);
gl.addComponent(1, 2, file);
OK, I am now reading files OK, but only if they are visible to the portal. For example, if I do a fileupload of c:\somewhere\a.xml everything works OK, but if I browse to y:\somewhere\a.xml, I have problems. I think this is because the J2EE engine doesn't know about y:. I am using BufferedReader.
How can I read a file from the client browser based on a filename that has been entered by FileUpload?
Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Michael,
Can you post your code. I use the following and it works for me.
//get the file
FileUpload rimage = (FileUpload) getComponentByName("imagefile");
if (rimage.getFile() != null) {
String mimetype = rimage.getFile().getContentType();
String resource = rimage.getFile().getFileName();
try {
FileInputStream sourceFileInput = new FileInputStream(rimage.getFile().getFile().getAbsolutePath());
} catch (Exception e) {
e.printStackTrace(); }
}
The FileInputStream was just what I needed!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Michael,
Can you post your complete code because the code you have posted doesn't tell us anything. I think you are missing the following lines.
Form myForm = myContext.createFormDocument("myform");
//this line is very important
<b>myForm.setEncodingType("multipart/form-data");</b>
PS: Please reward points if the problem is resolved or the answer is helpful.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.