Jan-06-2021, 10:46 AM
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!