Get URL of resource that is drag-and-dropped on field

前端 未结 3 1345
借酒劲吻你
借酒劲吻你 2020-12-31 13:40

I have an html page with a certain input field and I want to add the following functionality.

The user should be able to drag and drop a resource onto the field. The

3条回答
  •  时光说笑
    2020-12-31 14:12

    Do to security measures put in place by all modern browsers it is impossible to get the real full path of a file which has been drag and dropped into a browser.

    All major browsers now replace the file path with "/fakepath/'FileName'" where 'FileName' is the name of the file you selected.

    You can however still do drag and drop functionality and get JUST the file name of the file you dragged into the browser.

    Here is a jsfiddle of a modification of the answer to the related question noted in the comments of the question

    http://jsfiddle.net/c7cqN/

提交回复
热议问题