Get file extension from uploaded file

后端 未结 4 1001
陌清茗
陌清茗 2021-01-22 16:07

Here my requirement is to upload the file and to store it in the disk. I have no problem in storing it in disk, but getting the extension of the file. The problem is when I clic

4条回答
  •  灰色年华
    2021-01-22 16:44

    This worked for me

    Part filePart = request.getPart("input-file"); 
    String type=filePart.getContentType();
    type="."+type.substring(type.lastIndexOf("/")+1);
    

提交回复
热议问题