avatar
Untitled

Guest 645 19th Apr, 2021

import socket
import shutil
import os
import tkinter as tk

from tkinter.filedialog import asksaveasfilename

s = socket.socket()
s.bind(("localhost", 5000))
s.listen(1)
c,a = s.accept()

filetodown = open("pic1.jpg", "wb")
while True:
   data = c.recv(1024)
   if not data:
      break
   filetodown.write(data)
filetodown.close()

#ngang doan nay la send file xong. dung gui in no len man hinh a


# day la luu file vo tep
save_path = asksaveasfilename()
shutil.copyfile("pic1.jpg",save_path)

os.remove("pic1.jpg") #delete picture in source file
c.shutdown(2)
c.close()
s.close()
#Done :)
Markup
Description

No description

To share this paste please copy this url and send to your friends
RAW Paste Data