Simulate drop file event

后端 未结 2 1562
庸人自扰
庸人自扰 2020-11-28 09:16

Is it possible to simulate/fake the drop event using javascript only? How to test this type of event?

Take for example this dnd upload sample page , is it possible t

2条回答
  •  春和景丽
    2020-11-28 10:02

    @kol answer is a good way to get rid of the drag and drop event but I still have to manually select a file from my computer. This is the bit I am interested in simulating. Is there a way to create a file variable programatically? -caiocpricci2

    Try this

    function createFile() {
      var create = ["
    file
    "]; var blob = new Blob([create], {"type" : "text/html"}); return ( blob.size > 0 ? blob : "file creation error" ) }; createFile()

提交回复
热议问题