0

In my webapp I'm using the Noun Project API to create an icon picker for something they're creating. However, the Noun Project API gives me a URL to the icon that expires some time later. Ideally I can save the image to my Parse backend from the URL I'm given, but I have no idea how.

My assumption would've been to insert it into a file <input>, but apparently HTML won't allow that. If I could create a File object from the URL image then I could save that easily, but I couldn't figure out how to do that either.

If anyone has any idea how to save a remote image to Parse, I would greatly appreciate your input. Any and all solutions are welcome, pure JS or anything -- even PHP, I'm getting desperate.

tuckerchapin
  • 661
  • 2
  • 7
  • 25

2 Answers2

1

I don't know if I get you right but you can simply do that by adding a <a> tag and set the download prop of it to the url you want and finally call the click method of it. something like this:

var a = document.createElement('a');
a.download = filename; 
a.style.display = 'none';
document.body.appendChild(a);
a.click();
delete a;
Mr Lister
  • 45,515
  • 15
  • 108
  • 150
0

using php its fairly easy. One way is to use curl

$ch = curl_init($yoururl);
$fp = fopen('/my/folder/flower.gif', 'wb');
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
curl_close($ch);
fclose($fp);

Answer taken from Saving image from PHP URL. There are more options there as well.

Community
  • 1
  • 1
l0ckm4
  • 757
  • 5
  • 17