Retrieve the file name while using file type input

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

I have a jsp with this code snippet in it.

Choose Fil
5条回答
  •  情深已故
    2021-02-19 20:31

    Iterator iter = items.iterator();
    while (iter.hasNext()) {
        FileItem item = (FileItem) iter.next();
    
        if (item.isFormField()) {
           // Process a normal field
           String name = item.getFieldName();
           String value = item.getString();
    
        } else {
            // Process a file upload field 
        String fileName = item.getName();
        // DO further processing
    
        }
    }
    

提交回复
热议问题