Retrieve the file name while using file type input

前端 未结 5 1587
南旧
南旧 2021-02-19 19:58

I have a jsp with this code snippet in it.

Choose Fil
5条回答
  •  孤街浪徒
    2021-02-19 20:33

    use MultipartFile utility and try this

    MultipartRequest multipartRequest = (MultipartRequest) request;
                    Map map = multipartRequest.getFileMap();
                    MultipartFile mfile = null;
                    for (Iterator iter = map.values().iterator(); iter.hasNext();) {
                        mfile = (MultipartFile) iter.next();
                                    String fileName = mfile.getOriginalFilename()
        }
    

    Or you can try apache commons file upload.

    Check this link : http://commons.apache.org/fileupload/using.html

提交回复
热议问题