Uploading a png to imgur using javascript

匆匆过客 提交于 2019-12-03 07:55:08
Juho Vepsäläinen

The example you are using expects that you use input element (type=file) to upload some image. Try this example. You can access image data using a Canvas like this.

To summarize, you'll need to do this:

  1. Create new Image with your file (needs to be on local domain)
  2. Draw the image to a Canvas at onload
  3. Extract image data using this method
  4. Pass that data to imgur like here

The file has to be a File object created with the HTML5 fileAPI, you can't just give it a file name and expect it to work.

Javascript has no access to the filesystem, it can only access files that are given to it using either drag and drop or a file input.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!