简体   繁体   中英

How to upload files as url to <input type="text]

I would like to upload file to filetag with url Is there a way?

ex url ) http://localhost:800/mysong.mp3

<input type="file">

First of all pretty cool app (audio-cutter) build in React. Seems like intended to do the job at client side. I couldn't get it working on my laptop for some reason. I have a suggestion for you. Create an input field which takes in the url <input type="text"> and save the url value somewhere, may be create another attribute called url in the component's state. Also create a <button> to initiate downloading the file from the url input, and load that into the state file using a handler function which uses setState . Basically trigger almost same code as below in the handler function for the button:

    this.setState({
      file: "downloaded file object goes here!",
      paused: true,
      decoding: true,
      audioBuffer: null,
    })

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM