upload file from client to server without openFile dialog

后端 未结 2 1548
攒了一身酷
攒了一身酷 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:31

    You should post the contents of the file.

    That is what the browser does when using the file upload dialog. The browser opens the file and sends the contents over HTTP.

    For example, you can post the contents using wget --post-file=file.txt. On the server, you can then read the POST data to retrieve the contents of the file.

    0 讨论(0)
  • 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.

    0 讨论(0)
提交回复
热议问题