Uploading a file in Java Servlet

后端 未结 1 1303
别跟我提以往
别跟我提以往 2021-01-16 22:11

I have a Java Dynamic Web Project, and I\'m using TomCat v7.0.

I am new to web projects and I didn\'t quite understand how I can upload a file in one of my jsp pages

1条回答
  •  孤独总比滥情好
    2021-01-16 22:39

    Not providing the file path is a security feature of the browser.

    You have the file contents available in your code (InputStream filecontent) so you could use that or use one of the convenience methods on FileItem, e.g.

    item.write(new File("/path/to/myfile.txt"));
    

    0 讨论(0)
提交回复
热议问题