Get filename from input [type='file'] using jQuery

前端 未结 11 992
陌清茗
陌清茗 2020-12-23 20:15

This is the uploaded form.

11条回答
  •  醉梦人生
    2020-12-23 20:28

    Getting the file name is fairly easy. As matsko points out, you cannot get the full file path on the user's computer for security reasons.

    var file = $('#image_file')[0].files[0]
    if (file){
      console.log(file.name);
    }
    

提交回复
热议问题