-1

Here's a question that very few ask and is very hard to find solution for in the internet.

I would like to dynamically download an image from a html tag and save that image to a local folder and than change the tag to point to the new location of the image.

For example:

<img  src="http://example.com/Logo.png" 
alt="" width="232">

I want to download that image to a local folder,say, C:\Logo.png.

And change the code to:

<img  src="c:\Logo.png" 
alt="" width="232">

I know there are a lot of long solutions. I'm looking for a "tool" that's already out there or a really quick solution to accomplish this. There are more than 1000 tags to move.

  • 1
    Please look at https://stackoverflow.com/questions/7503130/relative-path-or-url-for-html-src-and-href-attributes or try `src="file:///C:/Logo.png"` – Rohan Kumar Jul 03 '17 at 04:01
  • that is not what i was looking for. but thanks anyway – Production PhotoStudio Jul 03 '17 at 04:12
  • please show your long solution, its not possible to save file/image to local folder using javasript without user interaction. – uingtea Jul 03 '17 at 04:19
  • long solution: use java to get the url and parse the server reply to a string and one by one download the image from the link. and change the link to the local downloaded path. save the new html and move on to a new one – Production PhotoStudio Jul 03 '17 at 04:30

1 Answers1

0

Downloading an image from the web to your disk and assigning a new src from a saved image in your disk are 2 different things. You need to first device a way to safely save the image to your drive i.e. using curl like this, once you've established how to download an image to your disk then its a matter of assigning the URI to your src (assuming your running it on local host).

Qiqo
  • 64
  • 5