Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import socket # Import socket module
- s = socket.socket() # Create a socket object
- host = '192.168.1.108' # Get local machine name
- port = 80 # Reserve a port for your service.
- postr="POST /upload/file-name=tosend.jpg HTTP /1.1"
- s.connect((host, port))
- f = open('tosend.jpg','rb')
- l = f.read(1024)
- print 'Sending...'
- s.send(postr)
- while(l):
- s.send(l)
- l=f.read(1024)
- f.close()
- print "Done Sending"
- s.shutdown(socket.SHUT_WR)
- print s.recv(1024)
- s.close # Close the socket when done
Add Comment
Please, Sign In to add comment