Ask coding questions

← Back to all posts
Save files to user's computer
LuisAFK

When I encode an image and try to save it, I can only save it on Replit's computer and not mine.

Answered by CosmicBear [earned 5 cycles]
View Answer
Voters
LuisAFK
Comments
hotnewtop
CosmicBear

You can't save file to a user's own computer. As @ch1ck3n said it would be a huge security risk. If website were able to save file to computers, they could potentially install malware. Also, if the code is running on the Replit computers, there is no way of saving it to your own computer as they are completely separate computers. It would be like you running code on your computer to save a file onto my computer.

ch1ck3n

@CosmicBear cooler daniel

CosmicBear

@ch1ck3n who is daniel?

LuisAFK

@CosmicBear but websites can download files

CosmicBear

@LuisAFK but your code is running on a virtual computer in its own environment. It is not running as a website.

LuisAFK

@CosmicBear but it could be implemented, like a special folder in the Replit computers where anything that gets put in there gets sent to the client and downloaded

CosmicBear

@LuisAFK that's not how it works. You will always have to manually download it or else it would be a security risk. And even if Replit tries to, your browser would block it and then your computer would block it and maybe your wifi and cloudflare too.

LuisAFK

@CosmicBear ok, but it's possible to implement something similar. For example, a special folder in Replit's computers and any files written there get added to a list on the client, a list of links, and when the user manually clicks the link, the file gets downloaded. And I know that can be done, because many websites do it, just click a link and download whatever file

CosmicBear

@LuisAFK well that's the same thing as the file saving to the Replit servers and you clicking download from your repl.

LuisAFK

@CosmicBear but can anyone download files, even if you aren't logged in?

CosmicBear

@LuisAFK test it out.

ch1ck3n

the user has to manually download the files because it would be a security risk

ch1ck3n

@ch1ck3n daniel