首页 > 解决方案 > 如何使用reactjs在上传文件中给出文件路径?

问题描述

我是新手,我的目标是上传文件并且应该获取文件路径,即,如果我从 D 驱动器上传文件,那么路径应该是“D:\files\hi.pdf”,但在这里我都不能上传文件我也找不到路径。我已经浏览了链接如何解决 C:\fakepath? 我试图在我的代码中应用,但没有成功。

这是代码:

 <>
        <div className="fileInput">
          <Input
            type="text"
            placeholder="File 1"
            id="file-path"
            readonly
            name="fileName"
            value={this.state.fileName}
          />
          <Input
            type="file"
            id="file-id"
            name="file"
            onChange={this.FileUpload}
          />
          <Button icon="paperclip" />
        </div>
        <Button onClick={this.handleSubmit}>Submit</Button>
      </>

这是完整的代码

任何人都可以在上传文件时帮助我上传和获取路径吗?

标签: reactjs

解决方案


推荐阅读