我的网络应用程序允许网络管理员将文件上传到服务器并将该文件命名为“文件名输入和文件输入”。在文件页面上,用户可以单击文件名并获取管理员上传的文件。我的问题是如何上传文件并使用 XML 获取输入的名称。我知道如何使用 JSP/servlet 将文件上传到服务器我只需要将文件名与上传到服务器的文件链接起来
谢谢
最佳答案
将文件保存到服务器时,您将创建一个新文件。您可以选择在此处设置名称。
String fileName = request.getParameter("fileName");
File baseDir = new File("/path/to/save/the/files/");
File file = new File(baseDir, fileName);
//here you receive the InputStream that holds the data from the file uploaded
//since I don't know how you're retrieving it, I'll put three dots
InputStream inputStream = ...
//save the file in disk...
关于java - 将文件上传到服务器并使用 xml 指向它,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23020975/