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)

Rohit
  • 11
  • 1
  • 2
    Any concrete use case? If your question is Download+host elsewhere, then this question is a duplicate of [Google chrome rehost image extension](http://stackoverflow.com/questions/11378630/google-chrome-rehost-image-extension/). If -in addition- you want to save the image on the user's computer, then the general answer is No, not possible, but [possible if you accept the fact that the save feature requires user interaction](http://stackoverflow.com/a/10473992/938089). – Rob W Sep 19 '12 at 21:10

1 Answers1

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.

François Beaufort
  • 4,843
  • 3
  • 29
  • 38