Let's say I have this element on the page:(假设我在页面上有此元素:)
<input id="image-file" type="file" />
This will create a button that allows the users of the web page to select a file via an OS "File open..." dialog in the browser.(这将创建一个按钮,允许网页用户通过浏览器中的OS“文件打开...”对话框选择文件。)
Let's say the user clicks said button, selects a file in the dialog, then clicks the "Ok" button to close the dialog.(假设用户单击该按钮,在对话框中选择一个文件,然后单击“确定”按钮以关闭对话框。)
The selected file name is now stored in:(所选文件名现在存储在:)
document.getElementById("image-file").value
Now, let's say that the server handles multi-part POSTs at the URL "/upload/image".(现在,假设服务器在URL“ / upload / image”处处理多部分POST。)
How do I send the file to "/upload/image"?(如何将文件发送到“ / upload / image”?)
Also, how do I listen for notification that the file is finished uploading?(另外,如何侦听文件上传完成的通知?)
ask by YummyBánhMì translate from so