0

这可能是一个简单的问题,但我现在真的很困惑。

我有以下 HTML 代码:

<form id="fileButtons">
    <input name="file" type="file" accept="text/*">
    <button id="uploadBtn" name="upload" type="button">
        <span><b>Upload</b></span>
    </button>
</form>

用户应该通过 type="file" 的输入从他的本地驱动器中选择一个文件。在此之后,他应该能够通过单击 id="uploadBtn" 的按钮来上传文件。所以在我的 JavaScript 中必须有这样的东西:

$(uploadBtn).click(function ()
{
    ws.send("some file I have had selected before");
});

所以现在我不知道如何访问选定的文件并将其推送到服务器。我会感谢任何帮助!

4

0 回答 0