Logic Machine Forum
Code to get icon from website! - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: Code to get icon from website! (/showthread.php?tid=5938)



Code to get icon from website! - phongvucba - 20.03.2025

Hi! I want to copy a file from the internet in png or jpg format to the LM memory card for use. I don't know how to copy that file, can someone help me?
For example, copy from here:
https://img.icons8.com/fluency/48/home.png
Then I want to copy that icon to a folder. Is it correct to use it like this?
-----------------------

dataweb = "Code to get icon from website"
if data then
a=io.writefile('/home/apps/store/data/lmcloud/icon.png', dataweb)
end
log(a)
----------------------
I am so happy to thank everyone !


RE: Code to get icon from website! - admin - 20.03.2025

Try this:
Code:
url = 'https://img.icons8.com/fluency/48/home.png'
data = require('socket.http').request(url)

if data then
  io.writefile('/home/apps/store/data/lmcloud/icon.png', data)
end



RE: Code to get icon from website! - phongvucba - 21.03.2025

Oh, so good! I have done!