开发者

How to select a file and load its binary content to a local variable (JS/HTML)

开发者 https://www.devze.com 2023-03-05 20:23 出处:网络
I want to send a file in a REST PUT request. The user should be able to choose the file he wan开发者_如何学Pythonts to load from his local machine. I need to load the file as binary content and send

I want to send a file in a REST PUT request. The user should be able to choose the file he wan开发者_如何学Pythonts to load from his local machine. I need to load the file as binary content and send it as part of the PUT request.

How can i let the user choose the file and load its binary content?


You should have a form with the enctype of multipart/form-data and the method equals PUT

<form method="PUT" enctype="multipart/form-data" action="http://myrestserver.com/">

User name: <input type="text" name="username" />
<br />
Password: <input type="password" name="password" />
<br />
File to upload: <input type="file" name="uploaded_file">
<br />
<input type="submit" value="Press"> to upload the file!

</form>
0

精彩评论

暂无评论...
验证码 换一张
取 消