Skip to content
Sign upLog in
← Back to Community

Save files to user's computer

Profile icon
LuisAFKHacker

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
Profile icon
LuisAFK
Comments
hotnewtop
Profile icon
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.

Profile icon
ch1ck3n

@CosmicBear
cooler daniel

Profile icon
CosmicBear

@ch1ck3n
who is daniel?

Profile icon
LuisAFK

@CosmicBear
but websites can download files

Profile icon
CosmicBear

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

Profile icon
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

Profile icon
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.

Profile icon
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

Profile icon
CosmicBear

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

Profile icon
LuisAFK

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

Profile icon
CosmicBear

@LuisAFK
test it out.

Profile icon
ch1ck3n

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

Profile icon
ch1ck3n

@ch1ck3n
daniel