Hello,
I hope you have already found a solution with the FileNotFoundException. Anyway
I'm going to tell you how I solved this.
I had the same problem: Upload an image through s:fileupload and save it in
anoter location.
Like you I got the FileNotFoundException.
1- You can't use only the fileName property of s:fileupload because this
fileName doesn't have the directory structure. It just have something like
this: bild.jpg
2- You have to locate the directory inside your application (where you want to
save your file) with such a code for example:
| Properties props = System.getProperties();
| String jbossServerHomeUrl = props.getProperty( "jboss.server.home.url");
|
Psst: with your debugger, you can browse the properties inside props, and see
what you have inside...
3- When you have your URL Please create an URI with it. And then create a file
based on you URI
| URI bckGUri = new URI( jbossServerHomeUrl );
| File ilogBackgroundsFile = new File( bckGUri );
| ilogBackgroundsFile.mkdirs();
|
Psst: If you forget the mkdirs(), you will have the FileNotFoudException again!!
4- Then write in your file
| String imageFileDir = props.getProperty("jboss.server.home.dir") +
File.separator + "bild.jpg";
| FileOutputStream fos = new FileOutputStream( imageFileDir );
| fos.write( byteArray );
|
Please be aware that I told of URL in part 3 but of Directories in part 4
Hope this will help!
Hope
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4071462#4071462
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4071462
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user