Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Client side (Updated to react to server's connection request)
- -- Make sure the modem is open on the side you're using
- rednet.open("left") -- Replace "left" with the side where your modem is placed
- -- Function to send a file to the server
- local function sendFile(serverID, fileName)
- local file = fs.open(fileName, "r")
- if file then
- local content = file.readAll()
- file.close()
- local message = {
- fileName = fileName,
- fileContent = content
- }
- rednet.send(serverID, message, "file_transfer")
- print("File sent to server.")
- else
- print("File not found.")
- end
- end
- -- Replace with the actual server ID
- local serverID = 123 -- Replace with the actual server's ID
- -- Replace with the file you want to send
- local fileName = "example.txt" -- Replace with the file you want to send
- -- Check if permission is needed before sending the file
- rednet.send(serverID, "PermissionRequest", "permission")
- local _, message, _ = rednet.receive()
- if message == "PermissionGranted" then
- sendFile(serverID, fileName)
- else
- print("Permission denied. File not sent.")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement