upload file from client to server without openFile dialog

后端 未结 2 1558
攒了一身酷
攒了一身酷 2020-12-12 05:02

i am trying to create an aspx page where i can directly upload a file from the client to the server without user intervention. I would like to do something like when the use

2条回答
  •  再見小時候
    2020-12-12 05:34

    It's not possible to upload a file without user interaction. He has to do an explicit action: drag & drop or select a file with a dialog window.

    This is because security reasons, imagine if a HTML page could upload to a remote server any file it wants, without the user has to select which one: it could upload user documents, settings, passwords or whatever it's accessible to the Windows user that run the browser. For the same reason even the value attribute often is ignored and not every browser handles the accept attribute too (you may, more or less, force a user to select the file you want before he can continue). For what I remember older versions of Firefox didn't even allow to programmatically click an input tag to upload files.

提交回复
热议问题