Skip to main content
2 of 3
added requested explanation
Roland Kofler
  • 11.7k
  • 3
  • 44
  • 83

Read the documentation:

Every command usable from the cli is also available through the HTTP API. For example:

ipfs swarm peers

curl http://127.0.0.1:5001/api/v0/swarm/peers

So for the command:

USAGE ipfs add ... - Add a file to ipfs.

ARGUMENTS

< path >... - The path to a file to be added to IPFS.

https://ipfs.io/docs/commands/#ipfs-add

the equivalent API call would be:

curl -F "image=@/home/bar.jpg" 127.0.0.1:5001/api/v0/add

If you want to use a webpage to upload a document into ipfs it should be something like

<form action="http://127.0.0.1:5001/api/v0/add">
  <input type="file" name="image" accept="image/*">
  <input type="submit">
</form>
Roland Kofler
  • 11.7k
  • 3
  • 44
  • 83