将上载图像保存到jsf 2.0中的本地系统文件夹中 [英] Save Upload image into local system folder in jsf 2.0

查看:157
本文介绍了将上载图像保存到jsf 2.0中的本地系统文件夹中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是jsf框架工作的新手.我在eclipse ide中使用jsf2.0.我尝试在jsf2.0中上传图像.我已上传图像但它存储在eclipse服务器上.问题是当我清理服务器上删除的图像.因此,我需要帮助,将照片上传到系统本地文件夹中.请找到并帮助我.

I am new to jsf frame work.I am using jsf2.0 in eclipse ide.I have try to upload a images in jsf2.0.I have uploaded the image but it stored on eclipse server.The problem is when i clean the server the images are deleted.So i need a help,to upload photo into system local folder.please find and help me.

推荐答案

您需要在new File(或new FileOutputStream)中指定绝对路径,具体取决于查找结果的方式文件).

You need to specify an absolute path in new File (or new FileOutputStream, depending on how you're locating the result file).

所以,不要

File file = new File("uploads/filename.ext");

但是愿意

File file = new File("/uploads/filename.ext");

(请注意开头的/)

通过这种方式,它将存储在磁盘文件系统中的确切位置上,而不是相对于启动JVM的目录.

This way it will be stored on exactly that location in the disk file system instead of relative to the directory from where the JVM is been started.

这篇关于将上载图像保存到jsf 2.0中的本地系统文件夹中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆