1

I am writing a chrome extension. I want to send an image on some webpage to my site.

Using chrome contextMenus, I can get the source url of that image. I want to know how to use that source to download it or to send it somewhere else. ( similar to save-as functionality provided by browser)

1

1 Answer 1

0

Here's what I would to to upload the URL of an image through context menus:

chrome.contextMenus.onClicked.addListener(function (info) {

  var data = new FormData();
  data.append('url', info.srcUrl);

  var xhr = new XMLHttpRequest();
  xhr.open('POST', 'http://mywebsite.com', true);
  xhr.onload = function(e) { console.log(e); }
  xhr.send(data);

});

Hope it helps.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.