I want to upload a file from my server (linux machine) to my client machine(Windows 10), however when i try to do that I'm only able to transfer a blank file to the clients machine but the file data is not transferred. Can someone please check my code below and tell me what's wrong with it.
#Client Code:
#Client Code:
elif command.lower() == "upload": file_name = s.recv(1024).decode() data2 = s.recv(1078000) new_file = open(file_name, "wb") while(data2): new_file.write(data2) data2 = s.recv(1078000) new_file.close() print("Recieved File")#Server Code:
elif command.lower() == "upload": client_socket.send(command.encode()) print("") file_path = input(str("Enter the file path to send: ")) file_name = input(str("Enter the file NAME to send: ")) client_socket.send(file_name.encode()) f = open(file_path, "rb") print('Sending file...') data = f.read(1078000) while(data): connectionSocket.send(data) data = f.read(1078000) f.close() print('Done sending')Thanks!
Larz60+ write Jan-06-2021, 10:56 AM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Links are frowned upon.
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Links are frowned upon.