Send script:
print("What file do you want to send ?")
input = read()
file = fs.open(input, "r")
rednet.open("left")
print("Connecting to the server...")
rednet.broadcast("connect")
event, id, msg = os.pullEvent("rednet_message")
if msg == "connected" then
print("Connected! sending file...")
while true do
local line = file.readLine()
rednet.broadcast(tonumber(line))
if line == nil then break end
end
end
print("Connection refused")
Server script:
while true do
rednet.open("left")
event, id, msg = os.pullEvent("rednet_message")
if msg == "connect" then
rednet.send("connected")
print("A FTP user has connected")
event, msg = os.pullEvent("rednet_message")
file = fs.open(msg, "w")
while true do
event, msg = os.pullEvent("rednet_message")
file.writeLine(line)
end
fs.close()
else
rednet.send("Denied")
end
end