Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rednet.open("back")
- local function receiveFile(targetPath, contents)
- local file = fs.open(targetPath, "w")
- if file then
- file.write(contents)
- file.close()
- print("Received file: " .. targetPath)
- else
- print("Error: Unable to save file " .. targetPath)
- end
- end
- while true do
- local senderID, message, protocol = rednet.receive("fileTransfer")
- if type(message) == "table" and #message == 2 then
- local targetPath = message[1]
- local contents = message[2]
- receiveFile(targetPath, contents)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement